@gheima/cli 0.7.0 → 0.8.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/CHANGELOG.md +14 -0
- package/dist/agents-md.js +56 -0
- package/dist/cli.js +29 -0
- package/dist/version.js +1 -1
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @gheima/cli
|
|
2
2
|
|
|
3
|
+
## 0.8.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- c2a2f09: `gheima agents` prints a short section for a repository's `AGENTS.md` that tells coding agents how the project deploys on Gheima: the linked service, the deploy and logs commands, and the exit codes. `--write` adds it to the file between markers, so running it again replaces it instead of adding a copy.
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- 83540e6: `streamLogs` now reconnects when the server ends a live tail. The API closes every tail after 30 minutes. A runtime tail resumes from the millisecond after the last line it yielded, the same step the live poll already uses. Lines are not repeated, and lines written while it reconnects are not lost. The iterator now ends only when you abort it or when a reconnect is refused (for example, a revoked key), and in that case it throws. `gheima logs -f` keeps tailing past 30 minutes.
|
|
12
|
+
- Updated dependencies [c4af7ee]
|
|
13
|
+
- Updated dependencies [83540e6]
|
|
14
|
+
- @gheima/contracts@0.2.1
|
|
15
|
+
- @gheima/sdk@0.5.0
|
|
16
|
+
|
|
3
17
|
## 0.7.0
|
|
4
18
|
|
|
5
19
|
### Minor Changes
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { existsSync, readFileSync, writeFileSync } from 'node:fs';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
/**
|
|
4
|
+
* `gheima agents`: the section of AGENTS.md that tells a coding agent how this project ships on
|
|
5
|
+
* Gheima. Agents read AGENTS.md at the repository root before they act, so a few lines there
|
|
6
|
+
* save each one rediscovering the CLI, its exit codes and where the docs are.
|
|
7
|
+
*
|
|
8
|
+
* The section sits between markers, so writing it again replaces it rather than stacking
|
|
9
|
+
* copies, and everything outside the markers is the repository's own and left untouched.
|
|
10
|
+
*/
|
|
11
|
+
export const AGENTS_FILE = 'AGENTS.md';
|
|
12
|
+
const START = '<!-- gheima:start -->';
|
|
13
|
+
const END = '<!-- gheima:end -->';
|
|
14
|
+
export function agentsSection(serviceName) {
|
|
15
|
+
const svc = serviceName ?? '<service>';
|
|
16
|
+
return [
|
|
17
|
+
START,
|
|
18
|
+
'## Deploying (Gheima)',
|
|
19
|
+
'',
|
|
20
|
+
`This project deploys to the Gheima service \`${svc}\`. Gheima builds it from the pushed`,
|
|
21
|
+
'branch of this repository; uncommitted or unpushed changes are not deployed.',
|
|
22
|
+
'',
|
|
23
|
+
'- Deploy and wait for the outcome: `npx @gheima/cli deploy --json` (exit 0 = live, 8 = the',
|
|
24
|
+
' deployment did not go live).',
|
|
25
|
+
'- Read logs: `npx @gheima/cli logs --json`. Status: `npx @gheima/cli services get ' +
|
|
26
|
+
`${svc} --json\`.`,
|
|
27
|
+
'- Auth comes from `gheima login` or `GHEIMA_API_KEY`. Never print or commit the key.',
|
|
28
|
+
'- Configuration is environment variables on the service, never committed `.env` files.',
|
|
29
|
+
'- Exit codes: 2 usage, 3 auth, 4 not found, 5 conflict or validation, 6 rate limited,',
|
|
30
|
+
' 7 network. Destructive commands need `--yes`: ask before passing it.',
|
|
31
|
+
'- Docs for agents: https://gheima.ma/llms.txt (append `.md` to any docs URL). MCP server:',
|
|
32
|
+
' https://gheima.ma/mcp.',
|
|
33
|
+
END,
|
|
34
|
+
].join('\n');
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Put the section into `dir/AGENTS.md`: replace an existing one in place, or append it.
|
|
38
|
+
* Returns what happened, for the command to report.
|
|
39
|
+
*/
|
|
40
|
+
export function upsertAgentsMd(dir, section) {
|
|
41
|
+
const path = join(dir, AGENTS_FILE);
|
|
42
|
+
if (!existsSync(path)) {
|
|
43
|
+
writeFileSync(path, `# AGENTS.md\n\n${section}\n`);
|
|
44
|
+
return 'created';
|
|
45
|
+
}
|
|
46
|
+
const current = readFileSync(path, 'utf8');
|
|
47
|
+
const start = current.indexOf(START);
|
|
48
|
+
const end = current.indexOf(END, start);
|
|
49
|
+
if (start !== -1 && end !== -1) {
|
|
50
|
+
writeFileSync(path, current.slice(0, start) + section + current.slice(end + END.length));
|
|
51
|
+
return 'updated';
|
|
52
|
+
}
|
|
53
|
+
const sep = current.endsWith('\n\n') ? '' : current.endsWith('\n') ? '\n' : '\n\n';
|
|
54
|
+
writeFileSync(path, `${current}${sep}${section}\n`);
|
|
55
|
+
return 'appended';
|
|
56
|
+
}
|
package/dist/cli.js
CHANGED
|
@@ -16,6 +16,7 @@ import { table, printJson, printJsonLine, spinner, success, info, color, isInter
|
|
|
16
16
|
import { completionScript } from './completion.js';
|
|
17
17
|
import { callOp, registerGenerated } from './generated.js';
|
|
18
18
|
import { findLink, toDotenv, writeLink } from './link.js';
|
|
19
|
+
import { AGENTS_FILE, agentsSection, upsertAgentsMd } from './agents-md.js';
|
|
19
20
|
import { defaultClientName, openBrowser, pollForApproval, startDeviceLogin, } from './device-login.js';
|
|
20
21
|
const program = new Command();
|
|
21
22
|
program
|
|
@@ -972,6 +973,34 @@ program
|
|
|
972
973
|
fail(err);
|
|
973
974
|
}
|
|
974
975
|
});
|
|
976
|
+
program
|
|
977
|
+
.command('agents')
|
|
978
|
+
.description(`Print the Gheima section for ${AGENTS_FILE}, so coding agents know how this project deploys`)
|
|
979
|
+
.option('--write', `add it to ${AGENTS_FILE} (replacing an earlier copy) instead of printing it`)
|
|
980
|
+
.action((opts, cmd) => {
|
|
981
|
+
const g = globals(cmd);
|
|
982
|
+
try {
|
|
983
|
+
// Offline on purpose: the link already names the service, and no key is needed to write
|
|
984
|
+
// a file. Unlinked, the section carries a placeholder to fill in.
|
|
985
|
+
const found = findLink();
|
|
986
|
+
const section = agentsSection(found?.link.serviceName);
|
|
987
|
+
if (!opts.write) {
|
|
988
|
+
if (g.json)
|
|
989
|
+
return printJson({ section });
|
|
990
|
+
return void process.stdout.write(section + '\n');
|
|
991
|
+
}
|
|
992
|
+
const dir = found?.dir ?? process.cwd();
|
|
993
|
+
const outcome = upsertAgentsMd(dir, section);
|
|
994
|
+
if (g.json)
|
|
995
|
+
return printJson({ file: `${dir}/${AGENTS_FILE}`, outcome });
|
|
996
|
+
success(`${outcome[0].toUpperCase()}${outcome.slice(1)} the Gheima section in ${dir}/${AGENTS_FILE}`);
|
|
997
|
+
if (!found)
|
|
998
|
+
info('No linked service here: run `gheima link <service>`, then run this again.');
|
|
999
|
+
}
|
|
1000
|
+
catch (err) {
|
|
1001
|
+
fail(err);
|
|
1002
|
+
}
|
|
1003
|
+
});
|
|
975
1004
|
program
|
|
976
1005
|
.command('deploy [service]')
|
|
977
1006
|
.description('Deploy, stream the build, and exit with the outcome (the linked service by default)')
|
package/dist/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// GENERATED by scripts/write-version.mjs from package.json. Do not edit.
|
|
2
|
-
export const VERSION = '0.
|
|
2
|
+
export const VERSION = '0.8.0';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gheima/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"description": "Command-line interface for the Gheima platform.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -35,8 +35,8 @@
|
|
|
35
35
|
"commander": "^12.1.0",
|
|
36
36
|
"undici": "^7.29.0",
|
|
37
37
|
"zod": "^4.4.3",
|
|
38
|
-
"@gheima/contracts": "0.2.
|
|
39
|
-
"@gheima/sdk": "0.
|
|
38
|
+
"@gheima/contracts": "0.2.1",
|
|
39
|
+
"@gheima/sdk": "0.5.0"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@arethetypeswrong/cli": "^0.18.5",
|