@homespunapps/cli 1.0.0 → 1.4.2
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 +15 -5
- package/dist/argv.js +69 -4
- package/dist/commands/agent.js +0 -20
- package/dist/commands/apps.js +54 -37
- package/dist/commands/attachment-delete.js +2 -19
- package/dist/commands/attachment-download.js +2 -22
- package/dist/commands/attachment-list.js +2 -22
- package/dist/commands/attachment-show.js +2 -19
- package/dist/commands/attachment-token.js +4 -44
- package/dist/commands/attachment-upload.js +2 -25
- package/dist/commands/attachment.js +9 -52
- package/dist/commands/claim.js +2 -30
- package/dist/commands/config.js +6 -35
- package/dist/commands/data.js +211 -24
- package/dist/commands/deploy.js +23 -28
- package/dist/commands/feedback.js +3 -44
- package/dist/commands/grant.js +158 -0
- package/dist/commands/ingest.js +85 -0
- package/dist/commands/key.js +20 -31
- package/dist/commands/logout.js +2 -28
- package/dist/commands/members.js +64 -32
- package/dist/commands/register.js +100 -51
- package/dist/commands/set-key.js +2 -32
- package/dist/commands/skill.js +3 -39
- package/dist/commands/taste.js +4 -49
- package/dist/device-flow.js +162 -0
- package/dist/help-catalog.js +1087 -0
- package/dist/index.js +28 -100
- package/dist/version.js +20 -6
- package/package.json +11 -11
package/dist/index.js
CHANGED
|
@@ -9,7 +9,8 @@
|
|
|
9
9
|
// Multiple environments live as named profiles in
|
|
10
10
|
// $XDG_CONFIG_HOME/homespun/config.json; pick one with --profile or HOMESPUN_PROFILE.
|
|
11
11
|
// Output is JSON by default. Every noun self-documents via --help.
|
|
12
|
-
import { parseArgs, ArgvError } from "./argv.js";
|
|
12
|
+
import { parseArgs, ArgvError, BOOLEAN_FLAGS } from "./argv.js";
|
|
13
|
+
import { nounSpec, renderNounHelp, renderRootHelp } from "./help-catalog.js";
|
|
13
14
|
/**
|
|
14
15
|
* Translate an ArgvError into the canonical `invalid_args` envelope and exit
|
|
15
16
|
* non-zero. The parser throws ArgvError up-front; assertKnownFlags throws it
|
|
@@ -25,92 +26,25 @@ function failArgvError(e) {
|
|
|
25
26
|
process.stderr.write(JSON.stringify({ error }) + "\n");
|
|
26
27
|
process.exit(1);
|
|
27
28
|
}
|
|
28
|
-
import { runAgent
|
|
29
|
-
import { runKey
|
|
30
|
-
import { runTaste
|
|
31
|
-
import { runFeedback
|
|
32
|
-
import { runConfig
|
|
33
|
-
import { runBlob
|
|
34
|
-
import { runSkill
|
|
35
|
-
import { runDeploy
|
|
36
|
-
import { runApps
|
|
37
|
-
import { runData
|
|
38
|
-
import { runMembers
|
|
29
|
+
import { runAgent } from "./commands/agent.js";
|
|
30
|
+
import { runKey } from "./commands/key.js";
|
|
31
|
+
import { runTaste } from "./commands/taste.js";
|
|
32
|
+
import { runFeedback } from "./commands/feedback.js";
|
|
33
|
+
import { runConfig } from "./commands/config.js";
|
|
34
|
+
import { runBlob } from "./commands/attachment.js";
|
|
35
|
+
import { runSkill } from "./commands/skill.js";
|
|
36
|
+
import { runDeploy } from "./commands/deploy.js";
|
|
37
|
+
import { runApps } from "./commands/apps.js";
|
|
38
|
+
import { runData } from "./commands/data.js";
|
|
39
|
+
import { runMembers } from "./commands/members.js";
|
|
40
|
+
import { runGrant } from "./commands/grant.js";
|
|
41
|
+
import { runIngest } from "./commands/ingest.js";
|
|
39
42
|
import { VERSION } from "./version.js";
|
|
40
43
|
import { HomespunApiError } from "@homespunapps/core";
|
|
41
44
|
import { failUpgradeRequired } from "./output.js";
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
homespun <command> [options]
|
|
46
|
-
|
|
47
|
-
v2 app commands (operate on an App — a persistent, deployed web app):
|
|
48
|
-
deploy Create or redeploy an app (POST /v1/apps or
|
|
49
|
-
/v1/apps/:id/versions) — the create->redeploy loop.
|
|
50
|
-
apps App lifecycle: list | show | update | delete | wake |
|
|
51
|
-
watch (stream the app's change feed as JSON-lines).
|
|
52
|
-
data Collection row CRUD for an app: list | get | upsert |
|
|
53
|
-
update | delete.
|
|
54
|
-
members App membership management: add | list | remove
|
|
55
|
-
(invite/attach a member by email, list, or remove).
|
|
56
|
-
|
|
57
|
-
Other noun groups:
|
|
58
|
-
key YOUR agent's API key (list | revoke).
|
|
59
|
-
taste YOUR agent's freeform UI taste notes
|
|
60
|
-
(get | set | clear) — presentation preferences the agent
|
|
61
|
-
has learned from human feedback and reads before
|
|
62
|
-
generating an app.
|
|
63
|
-
feedback One-shot feedback to the relay operator
|
|
64
|
-
(create | list) — bug reports, feature requests, notes.
|
|
65
|
-
attachment Binary attachments (upload | download | show | list |
|
|
66
|
-
delete | token <mint|revoke|list>). Attachments are
|
|
67
|
-
scoped to an agent or an App, and can be
|
|
68
|
-
referenced from input_data via \`format: homespun-attachment-id\`.
|
|
69
|
-
agent Agent identity on this machine (register | logout).
|
|
70
|
-
config CLI config inspection (show).
|
|
71
|
-
skill The relay's SKILL.md (show | version) — auto-updating;
|
|
72
|
-
no API key required.
|
|
73
|
-
|
|
74
|
-
Run \`homespun <command> --help\` for command-specific options.
|
|
75
|
-
|
|
76
|
-
Config:
|
|
77
|
-
HOMESPUN_URL Relay base URL. Override: --url <url>
|
|
78
|
-
HOMESPUN_API_KEY Agent API key. Override: --api-key <key>
|
|
79
|
-
HOMESPUN_PROFILE Active profile name. Override: --profile <name>
|
|
80
|
-
'homespun agent register' provisions the API key and saves it (with the URL) to
|
|
81
|
-
\${XDG_CONFIG_HOME:-~/.config}/homespun/config.json under a named profile —
|
|
82
|
-
afterwards commands need no env vars. Manage multiple environments
|
|
83
|
-
(dev/staging/prod) with 'homespun config list / use / add / rm'.
|
|
84
|
-
|
|
85
|
-
Global flags:
|
|
86
|
-
-h, --help Show help.
|
|
87
|
-
-v, --version Print version.
|
|
88
|
-
--profile <name> Pick a saved profile for this invocation (overrides
|
|
89
|
-
HOMESPUN_PROFILE and the saved 'current_profile').
|
|
90
|
-
--url <url> Relay base URL — bypasses profile selection entirely.
|
|
91
|
-
--api-key <key> Agent API key — bypasses profile selection entirely.
|
|
92
|
-
|
|
93
|
-
Output: stdout is machine-readable JSON; errors go to stderr as
|
|
94
|
-
{"error":{"code","message"}} with a non-zero exit.`;
|
|
95
|
-
// Flags that never take a value. `json` is kept here purely for forward-compat
|
|
96
|
-
// (JSON is currently the only output mode): accepting `--json` as a no-op bool
|
|
97
|
-
// means a future `--text`/`--json` toggle won't break existing invocations. It
|
|
98
|
-
// is intentionally undocumented in --help.
|
|
99
|
-
//
|
|
100
|
-
// `version` is deliberately NOT here: the top-level `-v` / `--version` is
|
|
101
|
-
// handled from rawArgv[0] before parseArgs runs, so it never needs to be a
|
|
102
|
-
// boolean flag — and keeping it out leaves room for a future noun-level
|
|
103
|
-
// `--version <n>` value flag without a collision.
|
|
104
|
-
const BOOLEAN_FLAGS = new Set([
|
|
105
|
-
"json",
|
|
106
|
-
"once",
|
|
107
|
-
"help",
|
|
108
|
-
"print-key",
|
|
109
|
-
"yes",
|
|
110
|
-
"plain",
|
|
111
|
-
// `homespun deploy --force` / `homespun apps ... --force`: override a compat gate.
|
|
112
|
-
"force",
|
|
113
|
-
]);
|
|
45
|
+
// BOOLEAN_FLAGS (flags that never take a value) lives in argv.ts next to the
|
|
46
|
+
// parser that consumes it, and is exported so tests parse with the real set
|
|
47
|
+
// instead of a per-test copy that can drift (#827).
|
|
114
48
|
async function main() {
|
|
115
49
|
const rawArgv = process.argv.slice(2);
|
|
116
50
|
// Version: handle before anything else.
|
|
@@ -124,7 +58,7 @@ async function main() {
|
|
|
124
58
|
noun === "-h" ||
|
|
125
59
|
noun === "--help" ||
|
|
126
60
|
noun === "help") {
|
|
127
|
-
process.stdout.write(
|
|
61
|
+
process.stdout.write(renderRootHelp() + "\n");
|
|
128
62
|
return;
|
|
129
63
|
}
|
|
130
64
|
let args;
|
|
@@ -137,20 +71,8 @@ async function main() {
|
|
|
137
71
|
}
|
|
138
72
|
throw e;
|
|
139
73
|
}
|
|
140
|
-
const
|
|
141
|
-
|
|
142
|
-
taste: tasteHelp,
|
|
143
|
-
feedback: feedbackHelp,
|
|
144
|
-
attachment: blobHelp,
|
|
145
|
-
agent: agentHelp,
|
|
146
|
-
config: configHelp,
|
|
147
|
-
skill: skillHelp,
|
|
148
|
-
deploy: deployHelp,
|
|
149
|
-
apps: appsHelp,
|
|
150
|
-
data: dataHelp,
|
|
151
|
-
members: membersHelp,
|
|
152
|
-
};
|
|
153
|
-
if (!(noun in helps)) {
|
|
74
|
+
const spec = nounSpec(noun);
|
|
75
|
+
if (!spec) {
|
|
154
76
|
process.stderr.write(JSON.stringify({
|
|
155
77
|
error: {
|
|
156
78
|
code: "unknown_command",
|
|
@@ -164,7 +86,7 @@ async function main() {
|
|
|
164
86
|
// the verb runner which reads its own xxxHelp). This pre-empt only fires
|
|
165
87
|
// when --help is the FIRST positional-equivalent — i.e. no verb given.
|
|
166
88
|
if (args.bools.has("help") && args.positionals.length === 0) {
|
|
167
|
-
process.stdout.write(
|
|
89
|
+
process.stdout.write(renderNounHelp(spec) + "\n");
|
|
168
90
|
return;
|
|
169
91
|
}
|
|
170
92
|
switch (noun) {
|
|
@@ -201,6 +123,12 @@ async function main() {
|
|
|
201
123
|
case "members":
|
|
202
124
|
await runMembers(args);
|
|
203
125
|
break;
|
|
126
|
+
case "grants":
|
|
127
|
+
await runGrant(args);
|
|
128
|
+
break;
|
|
129
|
+
case "ingest":
|
|
130
|
+
await runIngest(args);
|
|
131
|
+
break;
|
|
204
132
|
}
|
|
205
133
|
}
|
|
206
134
|
main().catch((err) => {
|
package/dist/version.js
CHANGED
|
@@ -1,11 +1,25 @@
|
|
|
1
1
|
// Single source of truth for the CLI version string.
|
|
2
2
|
//
|
|
3
3
|
// - `homespun --version` prints this verbatim.
|
|
4
|
-
// - Every HomespunClient construction passes it as `cliVersion`, which
|
|
5
|
-
// as the `x-homespun-cli-version` header on every relay request
|
|
4
|
+
// - Every HomespunClient construction passes it as `cliVersion`, which rides
|
|
5
|
+
// as the `x-homespun-cli-version` header on every relay request, driving the
|
|
6
6
|
// relay's version-skew check (HTTP 426 `cli_upgrade_required`).
|
|
7
7
|
//
|
|
8
|
-
//
|
|
9
|
-
//
|
|
10
|
-
//
|
|
11
|
-
|
|
8
|
+
// The value is read at runtime from THIS package's own `package.json`
|
|
9
|
+
// `version` field rather than hardcoded, so it can never drift from what npm
|
|
10
|
+
// published. Both the built `dist/version.js` and the source `src/version.ts`
|
|
11
|
+
// sit exactly one directory below the package root, so `../package.json`
|
|
12
|
+
// resolves the same in either location.
|
|
13
|
+
import { readFileSync } from "node:fs";
|
|
14
|
+
import { dirname, resolve } from "node:path";
|
|
15
|
+
import { fileURLToPath } from "node:url";
|
|
16
|
+
function readVersion() {
|
|
17
|
+
const here = dirname(fileURLToPath(import.meta.url));
|
|
18
|
+
const pkgPath = resolve(here, "..", "package.json");
|
|
19
|
+
const pkg = JSON.parse(readFileSync(pkgPath, "utf8"));
|
|
20
|
+
if (typeof pkg.version !== "string" || pkg.version.length === 0) {
|
|
21
|
+
throw new Error(`homespun CLI: missing version in ${pkgPath}`);
|
|
22
|
+
}
|
|
23
|
+
return pkg.version;
|
|
24
|
+
}
|
|
25
|
+
export const VERSION = readVersion();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@homespunapps/cli",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.2",
|
|
4
4
|
"description": "Command-line client for the Homespun relay: create apps, inspect state, send and watch events.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -11,14 +11,9 @@
|
|
|
11
11
|
"relay",
|
|
12
12
|
"human-in-the-loop"
|
|
13
13
|
],
|
|
14
|
-
"homepage": "https://
|
|
15
|
-
"repository": {
|
|
16
|
-
"type": "git",
|
|
17
|
-
"url": "git+https://github.com/aerolalit/homespun.git",
|
|
18
|
-
"directory": "packages/cli"
|
|
19
|
-
},
|
|
14
|
+
"homepage": "https://docs.homespun.dev",
|
|
20
15
|
"bugs": {
|
|
21
|
-
"url": "https://github.com/
|
|
16
|
+
"url": "https://github.com/homespunapps/homespun/issues"
|
|
22
17
|
},
|
|
23
18
|
"engines": {
|
|
24
19
|
"node": ">=20"
|
|
@@ -41,13 +36,18 @@
|
|
|
41
36
|
"test:unit": "vitest run"
|
|
42
37
|
},
|
|
43
38
|
"dependencies": {
|
|
44
|
-
"@homespunapps/core": "^1.
|
|
39
|
+
"@homespunapps/core": "^1.4.2",
|
|
45
40
|
"qrcode-terminal": "^0.12.0"
|
|
46
41
|
},
|
|
47
42
|
"devDependencies": {
|
|
48
|
-
"@types/node": "^
|
|
43
|
+
"@types/node": "^26.1.1",
|
|
49
44
|
"@types/qrcode-terminal": "^0.12.2",
|
|
50
|
-
"typescript": "^
|
|
45
|
+
"typescript": "^7.0.2",
|
|
51
46
|
"vitest": "^4.1.8"
|
|
47
|
+
},
|
|
48
|
+
"repository": {
|
|
49
|
+
"type": "git",
|
|
50
|
+
"url": "git+https://github.com/homespunapps/homespun.git",
|
|
51
|
+
"directory": "packages/cli"
|
|
52
52
|
}
|
|
53
53
|
}
|