@numericoach/gskills-admin-cli 0.1.0 → 0.1.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.
- package/README.md +2 -0
- package/dist/gskills-admin.js +47 -7
- package/package.json +1 -1
- package/skills/gskills-admin-cli/SKILL.md +12 -1
package/README.md
CHANGED
|
@@ -17,6 +17,8 @@ bun run gskills-admin sync run --target <instanceId> --only pages,quizzes --yes
|
|
|
17
17
|
```
|
|
18
18
|
|
|
19
19
|
Content-like resources default to `instanceId = "global"` when `--instance` is omitted.
|
|
20
|
+
Deletes require both `--force` and an exact `--confirm-delete <resource>:<id>` token.
|
|
21
|
+
CLI writes are logged in the GSkills admin logs with the authenticated user and CLI metadata.
|
|
20
22
|
|
|
21
23
|
## Agent skill
|
|
22
24
|
|
package/dist/gskills-admin.js
CHANGED
|
@@ -296,12 +296,23 @@ var openUrl = async (url) => {
|
|
|
296
296
|
};
|
|
297
297
|
|
|
298
298
|
// ../../src/cli/api-client.ts
|
|
299
|
+
var detectAgent = () => {
|
|
300
|
+
if (process.env.GSKILLS_CLI_AGENT)
|
|
301
|
+
return process.env.GSKILLS_CLI_AGENT;
|
|
302
|
+
if (process.env.CODEX_CI || process.env.CODEX_SHELL || process.env.CODEX_THREAD_ID)
|
|
303
|
+
return "codex";
|
|
304
|
+
if (process.env.CI)
|
|
305
|
+
return "ci";
|
|
306
|
+
return "manual";
|
|
307
|
+
};
|
|
299
308
|
var requestApi = async (path, init = {}) => {
|
|
300
309
|
const session = await getApiSession();
|
|
301
310
|
const response = await fetch(new URL(path, session.baseUrl), {
|
|
302
311
|
...init,
|
|
303
312
|
headers: {
|
|
304
313
|
accept: "application/json",
|
|
314
|
+
"x-gskills-cli-client": "gskills-admin-cli",
|
|
315
|
+
"x-gskills-cli-agent": detectAgent(),
|
|
305
316
|
...init.body ? { "content-type": "application/json" } : {},
|
|
306
317
|
...init.headers ?? {},
|
|
307
318
|
authorization: `Bearer ${session.token}`
|
|
@@ -598,12 +609,40 @@ var updateResource = async (resource, id, ctx) => {
|
|
|
598
609
|
});
|
|
599
610
|
};
|
|
600
611
|
var deleteResource = async (resource, id, ctx) => {
|
|
612
|
+
const expectedConfirmation = `${resource.name}:${id}`;
|
|
601
613
|
if (!hasFlag(ctx, "force")) {
|
|
602
|
-
throw new CliError("Delete requires --force", 2, {
|
|
614
|
+
throw new CliError("Delete requires --force", 2, {
|
|
615
|
+
id,
|
|
616
|
+
resource: resource.name,
|
|
617
|
+
warning: "This permanently deletes production data.",
|
|
618
|
+
requiredConfirmation: expectedConfirmation
|
|
619
|
+
});
|
|
603
620
|
}
|
|
604
|
-
if (
|
|
605
|
-
|
|
606
|
-
|
|
621
|
+
if (getStringFlag(ctx, "confirm-delete") !== expectedConfirmation) {
|
|
622
|
+
throw new CliError(`Delete requires --confirm-delete ${expectedConfirmation}`, 2, {
|
|
623
|
+
id,
|
|
624
|
+
resource: resource.name,
|
|
625
|
+
warning: "This permanently deletes production data.",
|
|
626
|
+
requiredConfirmation: expectedConfirmation,
|
|
627
|
+
usage: `gskills-admin ${resource.name} delete ${id} --force --confirm-delete ${expectedConfirmation}`
|
|
628
|
+
});
|
|
629
|
+
}
|
|
630
|
+
if (hasFlag(ctx, "dry-run")) {
|
|
631
|
+
return {
|
|
632
|
+
dryRun: true,
|
|
633
|
+
resource: resource.name,
|
|
634
|
+
id,
|
|
635
|
+
action: "delete",
|
|
636
|
+
confirmed: true,
|
|
637
|
+
warning: "This permanently deletes production data."
|
|
638
|
+
};
|
|
639
|
+
}
|
|
640
|
+
return requestApi(`/api/cli/${resource.name}/${id}`, {
|
|
641
|
+
method: "DELETE",
|
|
642
|
+
body: JSON.stringify({
|
|
643
|
+
confirmation: expectedConfirmation
|
|
644
|
+
})
|
|
645
|
+
});
|
|
607
646
|
};
|
|
608
647
|
var runSyncCommand = async (action, ctx) => {
|
|
609
648
|
if (!action || action === "help")
|
|
@@ -765,7 +804,7 @@ var schemaHelp = () => ({
|
|
|
765
804
|
{ name: `${resource.name} get`, args: ["id"], writes: false },
|
|
766
805
|
{ name: `${resource.name} create`, flags: ["--data", "--instance", "--dry-run"], writes: true },
|
|
767
806
|
{ name: `${resource.name} update`, args: ["id"], flags: ["--data", "--dry-run"], writes: true },
|
|
768
|
-
{ name: `${resource.name} delete`, args: ["id"], flags: ["--force", "--dry-run"], writes: true, destructive: true }
|
|
807
|
+
{ name: `${resource.name} delete`, args: ["id"], flags: ["--force", "--confirm-delete", "--dry-run"], writes: true, destructive: true }
|
|
769
808
|
])
|
|
770
809
|
],
|
|
771
810
|
resources: resources.map((resource) => ({
|
|
@@ -810,9 +849,10 @@ var resourceHelp = (resource) => ({
|
|
|
810
849
|
`gskills-admin ${resource.name} get <id>`,
|
|
811
850
|
`gskills-admin ${resource.name} create --data '{"instanceId":"global"}'`,
|
|
812
851
|
`gskills-admin ${resource.name} update <id> --data '{"disabled":true}'`,
|
|
813
|
-
`gskills-admin ${resource.name} delete <id> --force
|
|
852
|
+
`gskills-admin ${resource.name} delete <id> --force --confirm-delete ${resource.name}:<id>`
|
|
814
853
|
],
|
|
815
|
-
defaultFields: resource.defaultFields
|
|
854
|
+
defaultFields: resource.defaultFields,
|
|
855
|
+
deleteWarning: "Delete permanently removes production data and requires an exact --confirm-delete token."
|
|
816
856
|
});
|
|
817
857
|
|
|
818
858
|
// ../../src/cli/gskills-admin.ts
|
package/package.json
CHANGED
|
@@ -54,6 +54,17 @@ gskills-admin pages update <id> --data '{"disabled":false}' --dry-run --output j
|
|
|
54
54
|
|
|
55
55
|
5. Apply the exact same command without `--dry-run` only after the payload is correct.
|
|
56
56
|
|
|
57
|
+
Deletes are stricter than other writes. They require both `--force` and an exact confirmation token.
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
gskills-admin pages delete <id> --force --confirm-delete pages:<id> --dry-run --output json
|
|
61
|
+
gskills-admin pages delete <id> --force --confirm-delete pages:<id> --output json
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
Never add `--confirm-delete` unless the user explicitly asked for a permanent deletion and the target row was read first.
|
|
65
|
+
|
|
66
|
+
CLI create, update, and delete operations are written to the GSkills admin logs with the authenticated user, entity snapshots, and CLI metadata. When Codex runs the CLI, the log metadata includes `actorType = "cli"` and `agent = "codex"`.
|
|
67
|
+
|
|
57
68
|
## Instance Rules
|
|
58
69
|
|
|
59
70
|
If `--instance` is omitted, content-like resources default to `instanceId = "global"`.
|
|
@@ -138,7 +149,7 @@ gskills-admin sync run --target <instanceId> --pages <pageId,pageId> --languages
|
|
|
138
149
|
|
|
139
150
|
- Prefer `list` and `get` before writes
|
|
140
151
|
- Use `--dry-run` before create, update, delete, and sync
|
|
141
|
-
- Use `--force
|
|
152
|
+
- Use `--force --confirm-delete <resource>:<id>` only for deletes the user explicitly requested
|
|
142
153
|
- Re-read changed rows after writes
|
|
143
154
|
- Keep output structured so another agent can parse it
|
|
144
155
|
- If production behavior matters, separate code state, deploy state, and data state
|