gipity 1.1.16 → 1.1.20
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 +58 -75
- package/dist/adopt-cwd.js +2 -13
- package/dist/api.js +27 -45
- package/dist/auth.js +1 -1
- package/dist/banner.js +3 -7
- package/dist/catalog.js +8 -7
- package/dist/commands/add.js +26 -9
- package/dist/commands/approval.js +1 -1
- package/dist/commands/ask.js +112 -0
- package/dist/commands/bug.js +5 -5
- package/dist/commands/build.js +10 -35
- package/dist/commands/credits.js +3 -3
- package/dist/commands/doctor.js +7 -8
- package/dist/commands/email.js +6 -56
- package/dist/commands/generate.js +12 -12
- package/dist/commands/init.js +40 -30
- package/dist/commands/key.js +1 -1
- package/dist/commands/load.js +2 -12
- package/dist/commands/logs.js +2 -2
- package/dist/commands/memory.js +5 -17
- package/dist/commands/notify.js +1 -1
- package/dist/commands/page-eval.js +55 -38
- package/dist/commands/page-inspect.js +6 -6
- package/dist/commands/page-screenshot.js +51 -54
- package/dist/commands/page-test.js +188 -14
- package/dist/commands/payments.js +2 -2
- package/dist/commands/project.js +66 -15
- package/dist/commands/realtime.js +96 -4
- package/dist/commands/records.js +4 -6
- package/dist/commands/sandbox.js +2 -3
- package/dist/commands/skill.js +50 -22
- package/dist/commands/status.js +7 -9
- package/dist/commands/test.js +2 -2
- package/dist/commands/token.js +4 -4
- package/dist/commands/workflow.js +45 -8
- package/dist/config.js +22 -6
- package/dist/flag-aliases.js +75 -18
- package/dist/help-skills.js +2 -2
- package/dist/hooks/capture-runner.js +5 -3
- package/dist/index.js +1631 -1517
- package/dist/knowledge.js +24 -21
- package/dist/login-flow.js +4 -4
- package/dist/net.js +91 -0
- package/dist/opencode-setup.js +2 -2
- package/dist/page-fixtures.js +3 -3
- package/dist/project-setup.js +2 -3
- package/dist/prompts.js +1 -1
- package/dist/provider-docs.js +22 -25
- package/dist/realtime-bench.js +12040 -0
- package/dist/relay/agent-token.js +1 -1
- package/dist/relay/daemon.js +0 -1
- package/dist/relay/setup.js +13 -2
- package/dist/setup.js +11 -12
- package/dist/sync.js +3 -3
- package/dist/utils.js +1 -1
- package/package.json +10 -4
- package/dist/commands/agent.js +0 -251
- package/dist/commands/chat.js +0 -137
- package/dist/commands/claude.js +0 -1056
- package/dist/commands/plan.js +0 -93
package/dist/commands/sandbox.js
CHANGED
|
@@ -432,7 +432,7 @@ GCC/Rust).
|
|
|
432
432
|
console.error(clrError(`Scratch files are never mirrored into the sandbox, so it can't read: ${scratchReads.join(', ')}`));
|
|
433
433
|
console.error(dim(` ${SCRATCH_IGNORE.join(', ')} are ignored by sync, so the sandbox never sees them.`));
|
|
434
434
|
console.error(dim(' Stage the input at a real project path (src/, docs/, assets/) and delete it afterward.'));
|
|
435
|
-
console.error(dim(' (Writing OUTPUT under tmp/ is fine
|
|
435
|
+
console.error(dim(' (Writing OUTPUT under tmp/ is fine: scratch outputs come back to your local tmp/.)'));
|
|
436
436
|
process.exit(1);
|
|
437
437
|
}
|
|
438
438
|
}
|
|
@@ -468,8 +468,7 @@ GCC/Rust).
|
|
|
468
468
|
// Pull sandbox-written outputs down to the local cwd automatically. The
|
|
469
469
|
// server has already mirrored them into the project (VFS) and handed back
|
|
470
470
|
// the exact list, so honoring it here means files land locally without a
|
|
471
|
-
// manual `gipity sync
|
|
472
|
-
// `filesChanged` flag. Skip in one-off mode (no local project to sync into).
|
|
471
|
+
// manual `gipity sync`. Skip in one-off mode (no local project to sync into).
|
|
473
472
|
const pulledLocal = !!(res.data.outputFiles?.length && getConfigPath());
|
|
474
473
|
if (pulledLocal) {
|
|
475
474
|
await sync({ interactive: false, progress: opts.json ? undefined : createProgressReporter() });
|
package/dist/commands/skill.js
CHANGED
|
@@ -2,7 +2,7 @@ import { Command } from 'commander';
|
|
|
2
2
|
import { existsSync, readFileSync } from 'fs';
|
|
3
3
|
import { join } from 'path';
|
|
4
4
|
import { get } from '../api.js';
|
|
5
|
-
import {
|
|
5
|
+
import { getProjectRoot } from '../config.js';
|
|
6
6
|
import { error as clrError, bold, muted } from '../colors.js';
|
|
7
7
|
import { run, printList } from '../helpers/index.js';
|
|
8
8
|
/** Many kits ship a README but no skill doc. When `skill read <name>` misses
|
|
@@ -72,18 +72,53 @@ function tocText(sections) {
|
|
|
72
72
|
.map(s => `${String(s.start).padStart(5)} ${' '.repeat(s.level - 1)}${s.slug}${muted(` - ${s.title}`)}`)
|
|
73
73
|
.join('\n');
|
|
74
74
|
}
|
|
75
|
-
|
|
76
|
-
|
|
75
|
+
// Words that carry no meaning in a guessed slug (`functions-in-gipity-yaml`).
|
|
76
|
+
const SLUG_STOPWORDS = new Set(['a', 'an', 'and', 'the', 'in', 'of', 'on', 'to', 'for', 'with', 'via', 'how', 'from', 'your']);
|
|
77
|
+
function slugWords(slug) {
|
|
78
|
+
return slug.split('-').filter(w => w && !SLUG_STOPWORDS.has(w)).map(w => w.replace(/s$/, ''));
|
|
79
|
+
}
|
|
80
|
+
/** The section a guessed slug most plausibly means: the one sharing the most
|
|
81
|
+
* meaningful words with it (plural-insensitive, any order), provided it shares
|
|
82
|
+
* at least half of them and no other section ties. Slugs are only advertised
|
|
83
|
+
* by a full read or --toc, so an agent targeting a doc it hasn't read guesses
|
|
84
|
+
* (`functions-in-gipity-yaml` for `gipity-yaml-function-permissions`); serving
|
|
85
|
+
* the clear winner, labelled as such, saves the guess-and-correct turn. */
|
|
86
|
+
function closestSection(sections, want) {
|
|
87
|
+
const words = [...new Set(slugWords(want))];
|
|
88
|
+
if (words.length === 0)
|
|
89
|
+
return null;
|
|
90
|
+
const scored = sections.map(s => {
|
|
91
|
+
const have = new Set(slugWords(s.slug));
|
|
92
|
+
return { s, score: words.filter(w => have.has(w)).length };
|
|
93
|
+
}).sort((a, b) => b.score - a.score);
|
|
94
|
+
const [best, second] = scored;
|
|
95
|
+
if (!best || best.score * 2 < words.length || best.score === 0)
|
|
96
|
+
return null;
|
|
97
|
+
if (second && second.score === best.score)
|
|
98
|
+
return null;
|
|
99
|
+
return best.s;
|
|
100
|
+
}
|
|
101
|
+
/** Apply --toc / --section / --grep to a doc. Returns the text to print (plus a
|
|
102
|
+
* note when --section resolved to a closest match rather than the exact slug),
|
|
103
|
+
* or null when the filter matched nothing (caller reports it and exits 1). */
|
|
77
104
|
function filterContent(content, sections, opts) {
|
|
78
105
|
const lines = content.split('\n');
|
|
79
106
|
if (opts.toc)
|
|
80
|
-
return tocText(sections);
|
|
107
|
+
return { text: tocText(sections) };
|
|
81
108
|
let hits = [];
|
|
109
|
+
let note;
|
|
82
110
|
if (opts.section) {
|
|
83
111
|
const want = slugify(opts.section);
|
|
84
112
|
hits = sections.filter(s => s.slug === want);
|
|
85
113
|
if (hits.length === 0)
|
|
86
114
|
hits = sections.filter(s => s.slug.includes(want));
|
|
115
|
+
if (hits.length === 0) {
|
|
116
|
+
const closest = closestSection(sections, want);
|
|
117
|
+
if (closest) {
|
|
118
|
+
hits = [closest];
|
|
119
|
+
note = `No section "${opts.section}"; showing the closest match "${closest.slug}" (all slugs: --toc).`;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
87
122
|
}
|
|
88
123
|
else if (opts.grep) {
|
|
89
124
|
let re;
|
|
@@ -107,13 +142,13 @@ function filterContent(content, sections, opts) {
|
|
|
107
142
|
hits = sections.filter(s => matched.has(s));
|
|
108
143
|
}
|
|
109
144
|
else {
|
|
110
|
-
return content;
|
|
145
|
+
return { text: content };
|
|
111
146
|
}
|
|
112
147
|
if (hits.length === 0)
|
|
113
148
|
return null;
|
|
114
149
|
// Drop sections already contained in an outer hit so nothing prints twice.
|
|
115
150
|
const outer = hits.filter(s => !hits.some(o => o !== s && o.start <= s.start && s.end <= o.end));
|
|
116
|
-
return outer.map(s => sectionText(lines, s)).join('\n\n');
|
|
151
|
+
return { text: outer.map(s => sectionText(lines, s)).join('\n\n'), note };
|
|
117
152
|
}
|
|
118
153
|
export const skillCommand = new Command('skill')
|
|
119
154
|
.description('Task docs - read the matching skill before building');
|
|
@@ -122,12 +157,7 @@ skillCommand
|
|
|
122
157
|
.description('List skills')
|
|
123
158
|
.option('--json', 'Output as JSON')
|
|
124
159
|
.action((opts) => run('List', async () => {
|
|
125
|
-
const
|
|
126
|
-
if (!config.agentGuid) {
|
|
127
|
-
console.error(clrError('No agent configured for this project. Run `gipity init` to refresh.'));
|
|
128
|
-
process.exit(1);
|
|
129
|
-
}
|
|
130
|
-
const res = await get(`/skills?agent=${config.agentGuid}`);
|
|
160
|
+
const res = await get('/skills');
|
|
131
161
|
const width = res.data.reduce((m, s) => Math.max(m, s.name.length), 0);
|
|
132
162
|
printList(res.data, opts, 'No skills available.', s => ` ${bold(s.name.padEnd(width))} ${muted(s.description)}`, 'Read with `gipity skill read <name> [<name>...]` (one turn, many docs; `--toc`, `--section <slug>` or `--grep <term>` for one part):');
|
|
133
163
|
}));
|
|
@@ -135,16 +165,11 @@ skillCommand
|
|
|
135
165
|
.command('read <names...>')
|
|
136
166
|
.description('Read one or more skills (whole doc, or one part with --toc/--section/--grep)')
|
|
137
167
|
.option('--toc', 'Print the doc outline (section slugs + line numbers) instead of the content')
|
|
138
|
-
.option('--section <slug>', 'Print only this section (slug or heading text; subsections included)')
|
|
168
|
+
.option('--section <slug>', 'Print only this section (slug or heading text; subsections included). A guess that clearly matches one section by its words prints that section')
|
|
139
169
|
.option('--grep <term>', 'Print only the sections matching this term (case-insensitive regex)')
|
|
140
170
|
.option('--json', 'Output as JSON')
|
|
141
171
|
.action((names, opts) => run('Read', async () => {
|
|
142
|
-
const
|
|
143
|
-
if (!config.agentGuid) {
|
|
144
|
-
console.error(clrError('No agent configured for this project. Run `gipity init` to refresh.'));
|
|
145
|
-
process.exit(1);
|
|
146
|
-
}
|
|
147
|
-
const listRes = await get(`/skills?agent=${config.agentGuid}`);
|
|
172
|
+
const listRes = await get('/skills');
|
|
148
173
|
const jsonDocs = [];
|
|
149
174
|
let failed = false;
|
|
150
175
|
let printed = 0;
|
|
@@ -154,7 +179,7 @@ skillCommand
|
|
|
154
179
|
let detail;
|
|
155
180
|
let note = null;
|
|
156
181
|
if (match) {
|
|
157
|
-
const res = await get(`/skills/${match.guid}
|
|
182
|
+
const res = await get(`/skills/${match.guid}`);
|
|
158
183
|
content = res.data.content;
|
|
159
184
|
detail = { ...res.data };
|
|
160
185
|
}
|
|
@@ -183,7 +208,8 @@ skillCommand
|
|
|
183
208
|
if (opts.json) {
|
|
184
209
|
jsonDocs.push({
|
|
185
210
|
...detail,
|
|
186
|
-
content: filtered,
|
|
211
|
+
content: filtered.text,
|
|
212
|
+
...(filtered.note ? { note: filtered.note } : {}),
|
|
187
213
|
lines: lines.length,
|
|
188
214
|
sections: sections.map(s => ({ slug: s.slug, title: s.title, level: s.level, line: s.start })),
|
|
189
215
|
});
|
|
@@ -194,7 +220,9 @@ skillCommand
|
|
|
194
220
|
if (note)
|
|
195
221
|
console.log(note);
|
|
196
222
|
console.log(mapLine(name, lines, sections));
|
|
197
|
-
|
|
223
|
+
if (filtered.note)
|
|
224
|
+
console.log(muted(filtered.note));
|
|
225
|
+
console.log(filtered.text);
|
|
198
226
|
printed++;
|
|
199
227
|
}
|
|
200
228
|
if (opts.json) {
|
package/dist/commands/status.js
CHANGED
|
@@ -122,36 +122,34 @@ export const statusCommand = new Command('status')
|
|
|
122
122
|
// --api-base, or a disallowed host being dropped to the default). Surface
|
|
123
123
|
// the divergence rather than silently trusting the recorded value.
|
|
124
124
|
if (apiBaseInUse !== config.apiBase) {
|
|
125
|
-
console.log(`${muted('API (in use):')} ${warning(apiBaseInUse)} ${muted('(overrides .gipity.json
|
|
125
|
+
console.log(`${muted('API (in use):')} ${warning(apiBaseInUse)} ${muted('(overrides .gipity.json: GIPITY_API_BASE / --api-base / allowlist)')}`);
|
|
126
126
|
}
|
|
127
|
-
if (config.agentGuid)
|
|
128
|
-
console.log(`${muted('Agent:')} ${config.agentGuid}`);
|
|
129
127
|
}
|
|
130
128
|
if (usingEnvToken()) {
|
|
131
129
|
console.log(`${muted('Auth:')} ${probe.state === 'rejected'
|
|
132
|
-
? warning('agent API token (GIPITY_TOKEN) rejected by the server
|
|
133
|
-
: success('agent API token (GIPITY_TOKEN)')}${probe.state === 'unreachable' ? ` ${muted('(unverified
|
|
130
|
+
? warning('agent API token (GIPITY_TOKEN) rejected by the server. Mint a new one: gipity skill read agent-deploy')
|
|
131
|
+
: success('agent API token (GIPITY_TOKEN)')}${probe.state === 'unreachable' ? ` ${muted('(unverified: API unreachable)')}` : ''}`);
|
|
134
132
|
}
|
|
135
133
|
else if (!auth) {
|
|
136
134
|
console.log(`${muted('Auth:')} ${warning('not logged in. Run: gipity login')}`);
|
|
137
135
|
}
|
|
138
136
|
else if (probe.state === 'expired') {
|
|
139
|
-
console.log(`${muted('Auth:')} ${warning(`session expired for ${auth.email}. Run: gipity login (headless/CI: set GIPITY_TOKEN
|
|
137
|
+
console.log(`${muted('Auth:')} ${warning(`session expired for ${auth.email}. Run: gipity login (headless/CI: set GIPITY_TOKEN, see gipity skill read agent-deploy)`)}`);
|
|
140
138
|
}
|
|
141
139
|
else if (probe.state === 'rejected') {
|
|
142
140
|
// Locally fresh but the server says no (refresh token rotated away or
|
|
143
141
|
// revoked). Without the live probe this printed a green identity while
|
|
144
142
|
// every authenticated command failed.
|
|
145
|
-
console.log(`${muted('Auth:')} ${warning(`session for ${auth.email} was rejected by the server. Run: gipity login (headless/CI: set GIPITY_TOKEN
|
|
143
|
+
console.log(`${muted('Auth:')} ${warning(`session for ${auth.email} was rejected by the server. Run: gipity login (headless/CI: set GIPITY_TOKEN, see gipity skill read agent-deploy)`)}`);
|
|
146
144
|
}
|
|
147
145
|
else {
|
|
148
|
-
console.log(`${muted('Auth:')} ${success(auth.email)}${probe.state === 'unreachable' ? ` ${muted('(unverified
|
|
146
|
+
console.log(`${muted('Auth:')} ${success(auth.email)}${probe.state === 'unreachable' ? ` ${muted('(unverified: API unreachable)')}` : ''}`);
|
|
149
147
|
}
|
|
150
148
|
// Source-independent (session or GIPITY_TOKEN): a mismatch under an agent
|
|
151
149
|
// token is the same wrong-account class and must not be hidden inside the
|
|
152
150
|
// cascade above, which only special-cases 'rejected' for that source.
|
|
153
151
|
if (accountMismatch) {
|
|
154
|
-
console.log(`${muted('Account:')} ${warning(`logged-in account (${probe.account}) differs from this project's account (${config.accountSlug}). If you didn't expect this you may be logged into the wrong account
|
|
152
|
+
console.log(`${muted('Account:')} ${warning(`logged-in account (${probe.account}) differs from this project's account (${config.accountSlug}). If you didn't expect this you may be logged into the wrong account. Run: gipity login`)}`);
|
|
155
153
|
console.log(muted('(If this project was shared with you via gipity rbac, this is expected.)'));
|
|
156
154
|
}
|
|
157
155
|
if (queueDelivered > 0) {
|
package/dist/commands/test.js
CHANGED
|
@@ -276,7 +276,7 @@ export const testCommand = new Command('test')
|
|
|
276
276
|
testCommand
|
|
277
277
|
.command('status')
|
|
278
278
|
.alias('results')
|
|
279
|
-
.description('Fetch a finished (or running) test run by GUID
|
|
279
|
+
.description('Fetch a finished (or running) test run by GUID: full per-test results, no re-run')
|
|
280
280
|
.argument('<runGuid>', 'Test run GUID (e.g. tr_abc123)')
|
|
281
281
|
.option('--json', 'Output as JSON')
|
|
282
282
|
.option('--follow', 'Follow until complete (poll)')
|
|
@@ -320,7 +320,7 @@ testCommand
|
|
|
320
320
|
// ── List subcommand (show test files without running) ─────────────────
|
|
321
321
|
testCommand
|
|
322
322
|
.command('list')
|
|
323
|
-
.description('List the test files that would run
|
|
323
|
+
.description('List the test files that would run: no run, optional path filter')
|
|
324
324
|
.argument('[path]', 'Test path filter (e.g. "api", "e2e/portal")')
|
|
325
325
|
.option('--json', 'Output as JSON')
|
|
326
326
|
// optsWithGlobals: see the status subcommand — `--json` lands on the parent.
|
package/dist/commands/token.js
CHANGED
|
@@ -28,7 +28,7 @@ tokenCommand
|
|
|
28
28
|
body.expiresInDays = days;
|
|
29
29
|
}
|
|
30
30
|
const res = await post('/auth/agent-tokens', body);
|
|
31
|
-
const { token, shortGuid, expiresAt } = res.data;
|
|
31
|
+
const { token, short_guid: shortGuid, expires_at: expiresAt } = res.data;
|
|
32
32
|
if (opts.json) {
|
|
33
33
|
console.log(JSON.stringify(res.data));
|
|
34
34
|
return;
|
|
@@ -38,10 +38,10 @@ tokenCommand
|
|
|
38
38
|
console.log('');
|
|
39
39
|
console.log(token);
|
|
40
40
|
console.log('');
|
|
41
|
-
console.log(muted('Use it from an agent, script, or CI
|
|
41
|
+
console.log(muted('Use it from an agent, script, or CI (no login needed):'));
|
|
42
42
|
console.log(` export GIPITY_TOKEN=${token}`);
|
|
43
43
|
console.log('');
|
|
44
|
-
console.log(warning('Copy it now
|
|
44
|
+
console.log(warning('Copy it now. It will not be shown again.'));
|
|
45
45
|
}));
|
|
46
46
|
tokenCommand
|
|
47
47
|
.command('list')
|
|
@@ -63,7 +63,7 @@ tokenCommand
|
|
|
63
63
|
.action((shortGuid, opts) => run('Revoke', async () => {
|
|
64
64
|
await del(`/auth/agent-tokens/${encodeURIComponent(shortGuid)}`);
|
|
65
65
|
if (opts.json) {
|
|
66
|
-
console.log(JSON.stringify({ shortGuid, revoked: true }));
|
|
66
|
+
console.log(JSON.stringify({ short_guid: shortGuid, revoked: true }));
|
|
67
67
|
return;
|
|
68
68
|
}
|
|
69
69
|
console.log(success(`Revoked token ${bold(shortGuid)}.`));
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { Command, Option } from 'commander';
|
|
2
|
+
import { existsSync, mkdirSync, writeFileSync } from 'fs';
|
|
3
|
+
import { join } from 'path';
|
|
2
4
|
import { get, post, put, del } from '../api.js';
|
|
3
|
-
import { getConfig, requireConfig } from '../config.js';
|
|
5
|
+
import { getConfig, requireConfig, getProjectRoot } from '../config.js';
|
|
6
|
+
import { pushFile } from '../sync.js';
|
|
4
7
|
import { success, error as clrError, muted, bold } from '../colors.js';
|
|
5
8
|
import { run, printList, printResult } from '../helpers/index.js';
|
|
6
9
|
// `--json` is declared on the parent `workflow` command (so the bare list
|
|
@@ -273,7 +276,7 @@ workflowCommand
|
|
|
273
276
|
const wf = await resolveWorkflow(name);
|
|
274
277
|
const res = await put(`/workflows/${wf.short_guid}`, { is_active: true });
|
|
275
278
|
if (!res.data?.is_active) {
|
|
276
|
-
console.error(clrError(`Workflow "${wf.name}" is still inactive after enable
|
|
279
|
+
console.error(clrError(`Workflow "${wf.name}" is still inactive after enable: not enabled.`));
|
|
277
280
|
process.exit(1);
|
|
278
281
|
}
|
|
279
282
|
printResult(`Enabled "${wf.name}".`, opts, { enabled: wf.name, is_active: true });
|
|
@@ -287,29 +290,63 @@ workflowCommand
|
|
|
287
290
|
const wf = await resolveWorkflow(name);
|
|
288
291
|
const res = await put(`/workflows/${wf.short_guid}`, { is_active: false });
|
|
289
292
|
if (res.data?.is_active) {
|
|
290
|
-
console.error(clrError(`Workflow "${wf.name}" is still active after disable
|
|
293
|
+
console.error(clrError(`Workflow "${wf.name}" is still active after disable: not disabled.`));
|
|
291
294
|
process.exit(1);
|
|
292
295
|
}
|
|
293
296
|
printResult(`Disabled "${wf.name}".`, opts, { disabled: wf.name, is_active: false });
|
|
294
297
|
}));
|
|
298
|
+
const HEARTBEAT_PATH = 'workflows/heartbeat.yaml';
|
|
299
|
+
/** The `--heartbeat` starter: a daily llm step that keeps notes in project memory. */
|
|
300
|
+
const HEARTBEAT_YAML = `# A heartbeat: once a day, look at this project and keep notes in project memory.
|
|
301
|
+
# Edit the prompt and tools, then \`gipity deploy\` (or \`gipity workflow edit heartbeat --from ${HEARTBEAT_PATH}\`).
|
|
302
|
+
name: heartbeat
|
|
303
|
+
description: Daily check-in on this project, with notes kept in project memory.
|
|
304
|
+
trigger: schedule
|
|
305
|
+
cron: "0 9 * * *"
|
|
306
|
+
steps:
|
|
307
|
+
- name: check_in
|
|
308
|
+
prompt: |
|
|
309
|
+
Check in on this project. Read the "heartbeat" memory topic for what you noted last time.
|
|
310
|
+
Look at what changed since then and anything that needs attention.
|
|
311
|
+
Write the "heartbeat" memory topic again with what you saw and what to watch next time,
|
|
312
|
+
then return { summary, needs_attention } where needs_attention is a list of short strings.
|
|
313
|
+
tools: [memory, db_query]
|
|
314
|
+
`;
|
|
295
315
|
workflowCommand
|
|
296
316
|
.command('create')
|
|
297
317
|
.description('Create a workflow from a YAML file in the project (e.g. workflows/foo.yaml)')
|
|
298
|
-
.
|
|
318
|
+
.option('--from <path>', 'Project-relative YAML file path')
|
|
319
|
+
.option('--heartbeat', `Scaffold ${HEARTBEAT_PATH} (a daily check-in that keeps notes in project memory) and create it`)
|
|
299
320
|
.option('--name <name>', 'Override the name in the YAML')
|
|
300
321
|
.option('--json', 'Output as JSON')
|
|
301
322
|
.action((_opts, cmd) => run('Create', async () => {
|
|
302
323
|
const opts = mergedOpts(cmd);
|
|
303
324
|
const config = requireConfig();
|
|
325
|
+
if (opts.from && opts.heartbeat)
|
|
326
|
+
throw new Error('Pass --from <path> or --heartbeat, not both.');
|
|
327
|
+
if (!opts.from && !opts.heartbeat)
|
|
328
|
+
throw new Error('Pass --from <path> (a workflows/*.yaml file), or --heartbeat to start from a daily check-in.');
|
|
329
|
+
let from = opts.from;
|
|
330
|
+
if (opts.heartbeat) {
|
|
331
|
+
from = HEARTBEAT_PATH;
|
|
332
|
+
const root = getProjectRoot();
|
|
333
|
+
const local = join(root, HEARTBEAT_PATH);
|
|
334
|
+
// Never overwrite: an existing heartbeat.yaml is the user's edited copy.
|
|
335
|
+
if (!existsSync(local)) {
|
|
336
|
+
mkdirSync(join(root, 'workflows'), { recursive: true });
|
|
337
|
+
writeFileSync(local, HEARTBEAT_YAML);
|
|
338
|
+
}
|
|
339
|
+
await pushFile(local);
|
|
340
|
+
}
|
|
304
341
|
const body = {
|
|
305
|
-
config_yaml_path:
|
|
342
|
+
config_yaml_path: from,
|
|
306
343
|
project_guid: config.projectGuid,
|
|
307
344
|
};
|
|
308
345
|
if (opts.name)
|
|
309
346
|
body.name = opts.name;
|
|
310
347
|
const res = await post('/workflows', body);
|
|
311
348
|
const guid = res.data.short_guid ?? res.data.guid;
|
|
312
|
-
printResult(`Workflow created (${guid}).`, opts, { created: true, guid });
|
|
349
|
+
printResult(`Workflow created from ${from} (${guid}).`, opts, { created: true, guid, from });
|
|
313
350
|
}));
|
|
314
351
|
workflowCommand
|
|
315
352
|
.command('edit <name>')
|
|
@@ -339,7 +376,7 @@ workflowCommand
|
|
|
339
376
|
// actually went inactive rather than trusting the request was accepted.
|
|
340
377
|
const after = await get(`/workflows/${wf.short_guid}`);
|
|
341
378
|
if (after.data?.is_active) {
|
|
342
|
-
console.error(clrError(`Workflow "${wf.name}" (${wf.short_guid}) is still active
|
|
379
|
+
console.error(clrError(`Workflow "${wf.name}" (${wf.short_guid}) is still active: delete had no effect.`));
|
|
343
380
|
process.exit(1);
|
|
344
381
|
}
|
|
345
382
|
printResult(`Deleted "${wf.name}".`, opts, { deleted: wf.name, short_guid: wf.short_guid });
|
|
@@ -369,7 +406,7 @@ async function resolveWorkflow(name) {
|
|
|
369
406
|
const active = byName.filter(w => w.is_active);
|
|
370
407
|
if (active.length === 1)
|
|
371
408
|
return active[0];
|
|
372
|
-
console.error(clrError(`${byName.length} workflows named "${name}" in this project
|
|
409
|
+
console.error(clrError(`${byName.length} workflows named "${name}" in this project. Pass a short_guid:\n` +
|
|
373
410
|
byName.map(w => ` ${w.short_guid}${w.is_active ? '' : ' (inactive)'}`).join('\n')));
|
|
374
411
|
process.exit(1);
|
|
375
412
|
}
|
package/dist/config.js
CHANGED
|
@@ -57,7 +57,7 @@ export function resolveApiBase() {
|
|
|
57
57
|
return fromConfig;
|
|
58
58
|
if (!warnedHosts.has(fromConfig)) {
|
|
59
59
|
warnedHosts.add(fromConfig);
|
|
60
|
-
console.error(`⚠ Ignoring untrusted apiBase "${fromConfig}" from .gipity.json
|
|
60
|
+
console.error(`⚠ Ignoring untrusted apiBase "${fromConfig}" from .gipity.json: not a gipity.ai host. Using ${DEFAULT_API_BASE}.`);
|
|
61
61
|
}
|
|
62
62
|
}
|
|
63
63
|
return DEFAULT_API_BASE;
|
|
@@ -132,7 +132,6 @@ export async function resolveProjectContext(opts) {
|
|
|
132
132
|
console.error(`Project not found: ${target}`);
|
|
133
133
|
process.exit(1);
|
|
134
134
|
}
|
|
135
|
-
const agents = await get(`/projects/${match.short_guid}/agents`);
|
|
136
135
|
const accountSlug = await getAccountSlug();
|
|
137
136
|
console.error(dim(`→ (project: ${match.slug} · no file sync)`));
|
|
138
137
|
console.error('');
|
|
@@ -141,7 +140,6 @@ export async function resolveProjectContext(opts) {
|
|
|
141
140
|
projectGuid: match.short_guid,
|
|
142
141
|
projectSlug: match.slug,
|
|
143
142
|
accountSlug,
|
|
144
|
-
agentGuid: agents.data[0]?.short_guid ?? '',
|
|
145
143
|
conversationGuid: null,
|
|
146
144
|
apiBase: getApiBaseOverride() || DEFAULT_API_BASE,
|
|
147
145
|
ignore: [],
|
|
@@ -170,7 +168,6 @@ export async function resolveProjectContext(opts) {
|
|
|
170
168
|
projectGuid: res.data.projectGuid,
|
|
171
169
|
projectSlug: res.data.projectSlug,
|
|
172
170
|
accountSlug: res.data.accountSlug,
|
|
173
|
-
agentGuid: res.data.agentGuid ?? '',
|
|
174
171
|
conversationGuid: null,
|
|
175
172
|
apiBase: getApiBaseOverride() || DEFAULT_API_BASE,
|
|
176
173
|
ignore: [],
|
|
@@ -195,7 +192,7 @@ export function clearConfigCache() {
|
|
|
195
192
|
}
|
|
196
193
|
export function saveConfig(data) {
|
|
197
194
|
// saveConfig only ever *updates* an existing project config. It must never
|
|
198
|
-
// create a new `.gipity.json`: a one-off command (e.g. `gipity
|
|
195
|
+
// create a new `.gipity.json`: a one-off command (e.g. `gipity ask`) run
|
|
199
196
|
// in an unrelated folder resolves to the server's Home project, and a
|
|
200
197
|
// create-on-save here would silently turn that folder - in the wild, often
|
|
201
198
|
// `$HOME` itself - into a Gipity project. Creating a config is always an
|
|
@@ -203,7 +200,7 @@ export function saveConfig(data) {
|
|
|
203
200
|
const path = getConfigPath();
|
|
204
201
|
if (!path) {
|
|
205
202
|
throw new Error('saveConfig: no .gipity.json found to update. ' +
|
|
206
|
-
'Use saveConfigAt(dir,
|
|
203
|
+
'Use saveConfigAt(dir, ...) to create a new project config.');
|
|
207
204
|
}
|
|
208
205
|
writeFileSync(path, JSON.stringify(data, null, 2) + '\n');
|
|
209
206
|
cached = data;
|
|
@@ -214,10 +211,29 @@ export function saveConfig(data) {
|
|
|
214
211
|
* accidentally rewrite a parent project's config file. */
|
|
215
212
|
export function saveConfigAt(dir, data) {
|
|
216
213
|
const path = resolve(dir, CONFIG_FILE);
|
|
214
|
+
// A new project starts with session capture OFF: recording someone's coding
|
|
215
|
+
// sessions is opt-in (`gipity init --capture`). Existing configs keep what
|
|
216
|
+
// they have - an absent key there still means on, as it always has.
|
|
217
|
+
if (!existsSync(path) && data.captureHooks === undefined)
|
|
218
|
+
data = { ...data, captureHooks: false };
|
|
217
219
|
writeFileSync(path, JSON.stringify(data, null, 2) + '\n');
|
|
218
220
|
cached = data;
|
|
219
221
|
cachedPath = path;
|
|
220
222
|
}
|
|
223
|
+
/**
|
|
224
|
+
* Whether this project's coding-agent sessions are recorded to Gipity.
|
|
225
|
+
* GIPITY_CAPTURE=off always wins (the relay daemon owns capture for its
|
|
226
|
+
* dispatches), GIPITY_CAPTURE=on forces it (GipRunner scores builds from the
|
|
227
|
+
* recording), otherwise `.gipity.json` decides: new projects are created with
|
|
228
|
+
* `captureHooks: false`, and an older config without the key records.
|
|
229
|
+
*/
|
|
230
|
+
export function captureEnabled(config) {
|
|
231
|
+
if (process.env.GIPITY_CAPTURE === 'off')
|
|
232
|
+
return false;
|
|
233
|
+
if (process.env.GIPITY_CAPTURE === 'on')
|
|
234
|
+
return true;
|
|
235
|
+
return config?.captureHooks !== false;
|
|
236
|
+
}
|
|
221
237
|
/** Compiled matchers cached by their pattern set so the per-file `shouldIgnore`
|
|
222
238
|
* call in the sync loop doesn't rebuild the matcher every time. */
|
|
223
239
|
const ignoreMatcherCache = new Map();
|
package/dist/flag-aliases.js
CHANGED
|
@@ -37,8 +37,14 @@ export const FLAG_ALIASES = {
|
|
|
37
37
|
export function normalizeAliases(argv, program) {
|
|
38
38
|
// Flags the targeted command declares for real — never alias these, so a
|
|
39
39
|
// command's own option always wins over a global guess.
|
|
40
|
-
const
|
|
41
|
-
|
|
40
|
+
const target = program ? resolveTarget(argv, program) : null;
|
|
41
|
+
const realFlags = new Set();
|
|
42
|
+
for (const c of target?.chain ?? []) {
|
|
43
|
+
for (const opt of c.options)
|
|
44
|
+
if (opt.long)
|
|
45
|
+
realFlags.add(opt.long);
|
|
46
|
+
}
|
|
47
|
+
const aliased = argv.map(tok => {
|
|
42
48
|
if (!tok.startsWith('--'))
|
|
43
49
|
return tok;
|
|
44
50
|
const eq = tok.indexOf('=');
|
|
@@ -53,41 +59,92 @@ export function normalizeAliases(argv, program) {
|
|
|
53
59
|
return tok;
|
|
54
60
|
return FLAG_ALIASES[tok] ?? tok;
|
|
55
61
|
});
|
|
62
|
+
return target ? rewriteKeyValuePositionals(aliased, target) : aliased;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* `key=value` positional -> `--key=value`, when it can only have meant the flag.
|
|
66
|
+
*
|
|
67
|
+
* Agents keep carrying an option over as a bare `key=value` positional
|
|
68
|
+
* (`gipity add 2d-game title="Brick Breaker"`), the form many CLIs and
|
|
69
|
+
* Makefiles accept. Rather than error and cost a retry turn, read it as the
|
|
70
|
+
* option - but only when that is unambiguous: the token sits PAST the
|
|
71
|
+
* command's declared positionals (so it can't be a real argument that merely
|
|
72
|
+
* contains `=`, like a SQL string or an env assignment for `sandbox run`), the
|
|
73
|
+
* command has no variadic argument to soak it up, and `--key` (or its alias) is
|
|
74
|
+
* a value-taking option the targeted command actually declares. Anything else is
|
|
75
|
+
* left alone, so commander's excess-argument error still names it.
|
|
76
|
+
*/
|
|
77
|
+
function rewriteKeyValuePositionals(argv, target) {
|
|
78
|
+
const { leaf, chain, firstOperand } = target;
|
|
79
|
+
const declared = leaf.registeredArguments;
|
|
80
|
+
if (leaf.commands.length > 0 || declared.some(a => a.variadic))
|
|
81
|
+
return argv;
|
|
82
|
+
const options = chain.flatMap(c => c.options);
|
|
83
|
+
const byLong = new Map(options.filter(o => o.long).map(o => [o.long, o]));
|
|
84
|
+
const byShort = new Map(options.filter(o => o.short).map(o => [o.short, o]));
|
|
85
|
+
const takesValue = (tok) => {
|
|
86
|
+
if (tok.includes('='))
|
|
87
|
+
return false;
|
|
88
|
+
const o = byLong.get(tok) ?? byShort.get(tok);
|
|
89
|
+
return !!o && (o.required || o.optional);
|
|
90
|
+
};
|
|
91
|
+
const out = argv.slice();
|
|
92
|
+
let positional = 0;
|
|
93
|
+
for (let i = firstOperand; i < out.length; i++) {
|
|
94
|
+
const tok = out[i];
|
|
95
|
+
if (tok === '--')
|
|
96
|
+
break; // everything after is a literal operand
|
|
97
|
+
if (tok.startsWith('-')) {
|
|
98
|
+
if (takesValue(tok))
|
|
99
|
+
i++; // skip its value
|
|
100
|
+
continue;
|
|
101
|
+
}
|
|
102
|
+
const index = positional++;
|
|
103
|
+
if (index < declared.length)
|
|
104
|
+
continue;
|
|
105
|
+
const kv = /^([A-Za-z][\w-]*)=([\s\S]*)$/.exec(tok);
|
|
106
|
+
if (!kv)
|
|
107
|
+
continue;
|
|
108
|
+
const flag = [`--${kv[1]}`, FLAG_ALIASES[`--${kv[1]}`]].find(f => {
|
|
109
|
+
const o = f ? byLong.get(f) : undefined;
|
|
110
|
+
return !!o && (o.required || o.optional);
|
|
111
|
+
});
|
|
112
|
+
if (flag)
|
|
113
|
+
out[i] = `${flag}=${kv[2]}`;
|
|
114
|
+
}
|
|
115
|
+
return out;
|
|
56
116
|
}
|
|
57
117
|
/**
|
|
58
118
|
* Resolve the deepest subcommand argv targets (descending program → command →
|
|
59
|
-
* subcommand by name/alias)
|
|
60
|
-
*
|
|
119
|
+
* subcommand by name/alias). Used to suppress an alias when the resolved command
|
|
120
|
+
* owns that flag, and to find the command's operands.
|
|
61
121
|
*/
|
|
62
|
-
function
|
|
63
|
-
// process.argv is [node, script, ...args]; start scanning at the first arg.
|
|
64
|
-
const args = argv.slice(2);
|
|
122
|
+
export function resolveTarget(argv, program) {
|
|
65
123
|
let cmd = program;
|
|
66
124
|
const chain = [program];
|
|
67
125
|
// Root value-options (e.g. `--api-base <url>`) may legitimately precede the
|
|
68
126
|
// subcommand; skip them (and their value token) rather than ending resolution
|
|
69
127
|
// there, so a command's own flag is still discovered when a global flag leads.
|
|
70
128
|
const rootValueFlags = new Set(program.options.filter(o => o.long && o.required).map(o => o.long));
|
|
71
|
-
|
|
72
|
-
|
|
129
|
+
// process.argv is [node, script, ...args]; start scanning at the first arg.
|
|
130
|
+
let firstOperand = 2;
|
|
131
|
+
let operand;
|
|
132
|
+
for (let i = 2; i < argv.length; i++) {
|
|
133
|
+
const tok = argv[i];
|
|
73
134
|
if (tok.startsWith('-')) {
|
|
74
135
|
if (!tok.includes('=') && rootValueFlags.has(tok))
|
|
75
136
|
i++; // consume its value
|
|
76
137
|
continue;
|
|
77
138
|
}
|
|
78
139
|
const next = cmd.commands.find(c => c.name() === tok || c.aliases().includes(tok));
|
|
79
|
-
if (!next)
|
|
140
|
+
if (!next) {
|
|
141
|
+
operand = tok;
|
|
80
142
|
break;
|
|
143
|
+
}
|
|
81
144
|
cmd = next;
|
|
82
145
|
chain.push(next);
|
|
146
|
+
firstOperand = i + 1;
|
|
83
147
|
}
|
|
84
|
-
|
|
85
|
-
for (const c of chain) {
|
|
86
|
-
for (const opt of c.options) {
|
|
87
|
-
if (opt.long)
|
|
88
|
-
flags.add(opt.long);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
return flags;
|
|
148
|
+
return { chain, leaf: cmd, firstOperand, operand };
|
|
92
149
|
}
|
|
93
150
|
//# sourceMappingURL=flag-aliases.js.map
|
package/dist/help-skills.js
CHANGED
|
@@ -16,11 +16,11 @@ export async function fetchAndPrintSkill(skillName) {
|
|
|
16
16
|
const config = getConfig();
|
|
17
17
|
if (!config)
|
|
18
18
|
return;
|
|
19
|
-
const listRes = await get(
|
|
19
|
+
const listRes = await get('/skills');
|
|
20
20
|
const match = listRes.data.find(s => s.name.toLowerCase() === skillName.toLowerCase());
|
|
21
21
|
if (!match)
|
|
22
22
|
return;
|
|
23
|
-
const res = await get(`/skills/${match.guid}
|
|
23
|
+
const res = await get(`/skills/${match.guid}`);
|
|
24
24
|
if (res.data.content) {
|
|
25
25
|
console.log(muted(`\n── Skill: ${skillName} (auto-loaded from server) ──\n`));
|
|
26
26
|
console.log(res.data.content);
|
|
@@ -36,7 +36,9 @@
|
|
|
36
36
|
* - GIPITY_CAPTURE=off - the relay daemon owns capture for this run
|
|
37
37
|
* (it parses stream-json from stdout), or the caller opted out.
|
|
38
38
|
* - No binding resolvable: not a Gipity project, `captureHooks: false`
|
|
39
|
-
* in .gipity.json
|
|
39
|
+
* in .gipity.json (new projects start that way; GIPITY_CAPTURE=on
|
|
40
|
+
* overrides it, which is how GipRunner records its builds), or the
|
|
41
|
+
* resolve call failed.
|
|
40
42
|
* - The machine isn't paired - no device token available.
|
|
41
43
|
* - Anything unexpected (parse error, network error, etc.). We must
|
|
42
44
|
* not break the user's interactive session.
|
|
@@ -47,7 +49,7 @@ import { join } from 'path';
|
|
|
47
49
|
import { getDevice } from '../relay/state.js';
|
|
48
50
|
import { deviceFetch } from '../relay/device-http.js';
|
|
49
51
|
import { ImageBlockRewriter } from '../relay/media-upload.js';
|
|
50
|
-
import { getConfig } from '../config.js';
|
|
52
|
+
import { getConfig, captureEnabled } from '../config.js';
|
|
51
53
|
import { AGENT_ADAPTERS } from '../agents/index.js';
|
|
52
54
|
const CAPTURE_DIR = join(homedir(), '.gipity', 'capture-state');
|
|
53
55
|
const INGEST_BATCH_MAX = 100; // server caps at 200; stay comfortably under
|
|
@@ -273,7 +275,7 @@ export async function resolveConvGuid(hook, serverSource = 'claude_code', sleep
|
|
|
273
275
|
// (main() already checked the device, but resolveConvGuid is also the
|
|
274
276
|
// unit-tested entry - keep it self-sufficient).
|
|
275
277
|
const config = getConfig();
|
|
276
|
-
if (!config?.projectGuid || config
|
|
278
|
+
if (!config?.projectGuid || !captureEnabled(config))
|
|
277
279
|
return null;
|
|
278
280
|
if (!getDevice())
|
|
279
281
|
return null;
|