gipity 1.1.11 → 1.1.12
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 +3 -3
- package/dist/agents/index.js +2 -0
- package/dist/agents/opencode.js +143 -0
- package/dist/capture/sources/opencode.js +142 -0
- package/dist/commands/agent.js +14 -4
- package/dist/commands/build.js +8 -0
- package/dist/commands/generate.js +17 -2
- package/dist/index.js +797 -406
- package/dist/knowledge.js +2 -2
- package/dist/opencode-setup.js +171 -0
- package/dist/provider-docs.js +6 -8
- package/dist/relay/setup.js +10 -1
- package/dist/setup.js +31 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -23,7 +23,7 @@ irm https://gipity.ai/install.ps1 | iex
|
|
|
23
23
|
| You want to... | Run |
|
|
24
24
|
|----------------|-----|
|
|
25
25
|
| Start building right now, from anywhere | `gipity build` |
|
|
26
|
-
| Use your own workflow in your own directory | `gipity init`, then `claude` / `codex` / `grok` |
|
|
26
|
+
| Use your own workflow in your own directory | `gipity init`, then `claude` / `codex` / `grok` / `opencode` |
|
|
27
27
|
| Drive this computer from gipity.ai (phone, browser) | `gipity connect` |
|
|
28
28
|
|
|
29
29
|
### `gipity build` - start from anywhere
|
|
@@ -40,7 +40,7 @@ Prefer launching your agent yourself? From any project directory:
|
|
|
40
40
|
|
|
41
41
|
```bash
|
|
42
42
|
gipity init
|
|
43
|
-
claude # or codex, or
|
|
43
|
+
claude # or codex, grok, or opencode - whatever you use
|
|
44
44
|
```
|
|
45
45
|
|
|
46
46
|
`init` links the directory to a Gipity project, writes CLAUDE.md/AGENTS.md primers so your agent understands Gipity, and installs the Gipity skills + file-sync hooks into the agent CLIs found on your machine (Claude Code, Codex, Grok; Cursor and Gemini get primer files too).
|
|
@@ -126,7 +126,7 @@ gipity login --email you@example.com
|
|
|
126
126
|
gipity login --code 123456
|
|
127
127
|
cd my-project
|
|
128
128
|
gipity init
|
|
129
|
-
claude # or codex, or
|
|
129
|
+
claude # or codex, grok, or opencode
|
|
130
130
|
```
|
|
131
131
|
|
|
132
132
|
## Coding Agent Integration
|
package/dist/agents/index.js
CHANGED
|
@@ -2,12 +2,14 @@ import { claudeCodeAdapter } from './claude-code.js';
|
|
|
2
2
|
import { codexAdapter } from './codex.js';
|
|
3
3
|
import { grokAdapter } from './grok.js';
|
|
4
4
|
import { agyAdapter } from './agy.js';
|
|
5
|
+
import { opencodeAdapter } from './opencode.js';
|
|
5
6
|
/** Picker/help order: Claude first (the default), then the others. */
|
|
6
7
|
export const AGENT_ADAPTERS = [
|
|
7
8
|
claudeCodeAdapter,
|
|
8
9
|
codexAdapter,
|
|
9
10
|
grokAdapter,
|
|
10
11
|
agyAdapter,
|
|
12
|
+
opencodeAdapter,
|
|
11
13
|
];
|
|
12
14
|
export const AGENT_KEYS = AGENT_ADAPTERS.map(a => a.key);
|
|
13
15
|
export function getAdapter(key) {
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* opencode adapter (opencode.ai, Anomaly - vanilla opencode, never a fork).
|
|
3
|
+
* Flag surface per the opencode 1.18.x CLI docs: `opencode run [message..]`
|
|
4
|
+
* for headless one-shots with `--model provider/model`, `--session <id>` to
|
|
5
|
+
* continue, `--auto` to auto-approve permissions, `--format json`.
|
|
6
|
+
*
|
|
7
|
+
* Models: the Gipity opencode plugin registers a "gipity" provider - the
|
|
8
|
+
* curated open coding models (DeepSeek / Qwen / Kimi / GLM families) billed
|
|
9
|
+
* via the user's Gipity credits through the platform's serving path. A
|
|
10
|
+
* `--model` value with no provider prefix (a Gipity id or family alias like
|
|
11
|
+
* `deepseek`) is therefore namespaced to `gipity/…` here; opencode-native
|
|
12
|
+
* refs (`anthropic/…`, `openrouter/…`) pass through for BYO-key users.
|
|
13
|
+
*
|
|
14
|
+
* Capture: opencode fires no Claude-format hooks, but it loads plugins in
|
|
15
|
+
* every mode (TUI, `run`, serve). The Gipity plugin mirrors sessions itself -
|
|
16
|
+
* on session.idle it writes a normalized transcript to
|
|
17
|
+
* ~/.gipity/opencode/transcripts/<session_id>.jsonl and invokes the capture
|
|
18
|
+
* runner (`capture.cjs opencode stop`), riding the same ingest spine as every
|
|
19
|
+
* other agent. No launcher-driven replay hack needed (that path exists for
|
|
20
|
+
* Grok because grok -p fires nothing; opencode's plugin bus fires everywhere).
|
|
21
|
+
*/
|
|
22
|
+
import { homedir } from 'os';
|
|
23
|
+
import { join } from 'path';
|
|
24
|
+
import { hasEnvPrefix } from './types.js';
|
|
25
|
+
import { planForInstall, whichFirst } from './self-update.js';
|
|
26
|
+
import { parseTranscript as parseOpencodeTranscript } from '../capture/sources/opencode.js';
|
|
27
|
+
import { OPENCODE_PACKAGE, ensureOpencodeInstalled, ensureOpencodePluginInstalled, ensureOpencodeModelToken, opencodePluginState, removeOpencodePlugin, } from '../opencode-setup.js';
|
|
28
|
+
import { ensureOpencodeSkillsInstalled, removeAgentSkills } from '../setup.js';
|
|
29
|
+
/** opencode's own built-in provider namespaces. A --model whose first segment
|
|
30
|
+
* is one of these is an opencode-native ref (BYO key) and passes through;
|
|
31
|
+
* anything else is treated as a Gipity model id/alias and namespaced to the
|
|
32
|
+
* plugin's "gipity" provider. */
|
|
33
|
+
const OPENCODE_NATIVE_PROVIDERS = new Set([
|
|
34
|
+
'gipity', 'anthropic', 'openai', 'google', 'openrouter', 'xai', 'groq',
|
|
35
|
+
'mistral', 'azure', 'amazon-bedrock', 'github-copilot', 'opencode',
|
|
36
|
+
]);
|
|
37
|
+
function toOpencodeModel(model) {
|
|
38
|
+
const head = model.split('/', 1)[0];
|
|
39
|
+
return OPENCODE_NATIVE_PROVIDERS.has(head) ? model : `gipity/${model}`;
|
|
40
|
+
}
|
|
41
|
+
export const opencodeAdapter = {
|
|
42
|
+
key: 'opencode',
|
|
43
|
+
source: 'opencode',
|
|
44
|
+
harness: 'opencode',
|
|
45
|
+
displayName: 'opencode',
|
|
46
|
+
providerName: 'Anomaly',
|
|
47
|
+
binary: 'opencode',
|
|
48
|
+
buildInteractiveArgs({ resume, model }) {
|
|
49
|
+
const args = [];
|
|
50
|
+
if (model)
|
|
51
|
+
args.push('--model', toOpencodeModel(model));
|
|
52
|
+
if (resume)
|
|
53
|
+
args.push('--session', resume);
|
|
54
|
+
return args;
|
|
55
|
+
},
|
|
56
|
+
buildHeadlessArgs({ message, resume, model, bypassApprovals, jsonStream }) {
|
|
57
|
+
const args = ['run', message];
|
|
58
|
+
if (model)
|
|
59
|
+
args.push('--model', toOpencodeModel(model));
|
|
60
|
+
if (resume)
|
|
61
|
+
args.push('--session', resume);
|
|
62
|
+
if (bypassApprovals)
|
|
63
|
+
args.push('--auto');
|
|
64
|
+
if (jsonStream)
|
|
65
|
+
args.push('--format', 'json');
|
|
66
|
+
return args;
|
|
67
|
+
},
|
|
68
|
+
sessionIdFromStreamEvent(event) {
|
|
69
|
+
// `opencode run --format json` emits bus events; session ids ride
|
|
70
|
+
// properties.sessionID (message/part events) or properties.info.id
|
|
71
|
+
// (session.created/updated).
|
|
72
|
+
const fromProps = event?.properties?.sessionID;
|
|
73
|
+
if (typeof fromProps === 'string' && fromProps)
|
|
74
|
+
return fromProps;
|
|
75
|
+
const fromInfo = event?.properties?.info?.id;
|
|
76
|
+
if (typeof fromInfo === 'string' && fromInfo.startsWith('ses'))
|
|
77
|
+
return fromInfo;
|
|
78
|
+
return null;
|
|
79
|
+
},
|
|
80
|
+
hooksSupportedOnPlatform() {
|
|
81
|
+
return true; // plugin-based capture; no OS-specific hook files
|
|
82
|
+
},
|
|
83
|
+
daemonStreamCapture: false,
|
|
84
|
+
ensureInstalled() {
|
|
85
|
+
return ensureOpencodeInstalled();
|
|
86
|
+
},
|
|
87
|
+
// Plain literal, not `npm install -g ${OPENCODE_PACKAGE}`: this module sits
|
|
88
|
+
// in an import cycle (opencode.ts -> opencode-setup.ts -> setup.ts -> ...
|
|
89
|
+
// -> agents/index.ts -> opencode.ts), so a module-eval read of an imported
|
|
90
|
+
// binding hits the TDZ when the cycle is entered from setup.ts's side.
|
|
91
|
+
// Function bodies (updatePlan below) read the live binding safely.
|
|
92
|
+
installHint: 'npm install -g opencode-ai (or: curl -fsSL https://opencode.ai/install | bash)',
|
|
93
|
+
updatePlan() {
|
|
94
|
+
// Same-channel rule: npm-global installs update via npm; anything else
|
|
95
|
+
// (the curl installer) gets opencode's own `opencode upgrade`.
|
|
96
|
+
return planForInstall(whichFirst('opencode'), OPENCODE_PACKAGE, ['opencode', 'upgrade']);
|
|
97
|
+
},
|
|
98
|
+
async prepareLaunch() {
|
|
99
|
+
// The model slot needs a long-lived token before opencode starts (the
|
|
100
|
+
// plugin reads it at provider-auth time). Mint/refresh is a no-op when
|
|
101
|
+
// one is already valid.
|
|
102
|
+
await ensureOpencodeModelToken();
|
|
103
|
+
},
|
|
104
|
+
detectEnv() {
|
|
105
|
+
// The Gipity plugin injects OPENCODE_SESSION_ID into every shell opencode
|
|
106
|
+
// spawns (shell.env hook); opencode itself may leak other OPENCODE_* vars.
|
|
107
|
+
if (!hasEnvPrefix('OPENCODE'))
|
|
108
|
+
return null;
|
|
109
|
+
return { harness: 'opencode', harnessSession: process.env.OPENCODE_SESSION_ID };
|
|
110
|
+
},
|
|
111
|
+
capture: {
|
|
112
|
+
hookKey: 'opencode',
|
|
113
|
+
parse: (content, afterUuid) => parseOpencodeTranscript(content, afterUuid),
|
|
114
|
+
// The plugin writes the transcript at a derivable path, so a hook payload
|
|
115
|
+
// without transcript_path still resolves.
|
|
116
|
+
resolveTranscriptPath: (hook) => {
|
|
117
|
+
if (!hook.session_id)
|
|
118
|
+
return null;
|
|
119
|
+
const gipityDir = process.env.GIPITY_DIR || join(homedir(), '.gipity');
|
|
120
|
+
return join(gipityDir, 'opencode', 'transcripts', `${hook.session_id}.jsonl`);
|
|
121
|
+
},
|
|
122
|
+
},
|
|
123
|
+
setup: {
|
|
124
|
+
state: () => opencodePluginState(),
|
|
125
|
+
install: () => {
|
|
126
|
+
ensureOpencodeSkillsInstalled();
|
|
127
|
+
ensureOpencodePluginInstalled();
|
|
128
|
+
},
|
|
129
|
+
uninstall: () => {
|
|
130
|
+
const removedPlugin = removeOpencodePlugin();
|
|
131
|
+
const n = removeAgentSkills();
|
|
132
|
+
if (!removedPlugin && !n)
|
|
133
|
+
return null;
|
|
134
|
+
const parts = [];
|
|
135
|
+
if (removedPlugin)
|
|
136
|
+
parts.push('Gipity plugin removed from opencode.');
|
|
137
|
+
if (n)
|
|
138
|
+
parts.push(`Removed ${n} Gipity skills from ~/.agents/skills.`);
|
|
139
|
+
return parts.join(' ');
|
|
140
|
+
},
|
|
141
|
+
},
|
|
142
|
+
};
|
|
143
|
+
//# sourceMappingURL=opencode.js.map
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* opencode transcript JSONL → ingest entries.
|
|
3
|
+
*
|
|
4
|
+
* opencode does not write a single transcript file itself - it persists
|
|
5
|
+
* sessions as per-message JSON blobs in its own storage dir. The Gipity
|
|
6
|
+
* opencode plugin (installed to ~/.config/opencode/plugins/gipity.js by
|
|
7
|
+
* `gipity` setup, shipped in the GipityAI/skills repo) bridges that gap: on
|
|
8
|
+
* every `session.idle` it fetches the full message list over the opencode
|
|
9
|
+
* server SDK and rewrites
|
|
10
|
+
* ~/.gipity/opencode/transcripts/<session_id>.jsonl
|
|
11
|
+
* with one line per message, then invokes the capture runner (`capture.cjs
|
|
12
|
+
* opencode stop`). Line shape (SDK types, opencode 1.18.x):
|
|
13
|
+
*
|
|
14
|
+
* { info: UserMessage | AssistantMessage, parts: Part[] }
|
|
15
|
+
*
|
|
16
|
+
* info.role 'user' → prompt entry (joined text parts; synthetic parts
|
|
17
|
+
* are plugin/system injections and are skipped)
|
|
18
|
+
* info.role 'assistant' → assistant entry (text, tokens, modelID, finish)
|
|
19
|
+
* + tool_use per tool part (stable `callID`)
|
|
20
|
+
* + tool_result per completed/errored tool part
|
|
21
|
+
* reasoning / step-start / step-finish / file / snapshot parts → SKIP
|
|
22
|
+
*
|
|
23
|
+
* Dedup/watermark: message ids (`msg_…`) are stable and ordered, so the
|
|
24
|
+
* watermark is the last message id emitted. The file is fully rewritten each
|
|
25
|
+
* idle; a watermark that no longer appears (deleted/forked session) makes the
|
|
26
|
+
* caller replay from the top, and the server's source_uuid unique index
|
|
27
|
+
* collapses anything already forwarded. tool_use/tool_result key off the
|
|
28
|
+
* stable `callID`, which survives rewrites.
|
|
29
|
+
*/
|
|
30
|
+
function toIso(ms) {
|
|
31
|
+
return typeof ms === 'number' && ms > 0 ? new Date(ms).toISOString() : undefined;
|
|
32
|
+
}
|
|
33
|
+
function joinTextParts(parts) {
|
|
34
|
+
const out = [];
|
|
35
|
+
for (const p of parts) {
|
|
36
|
+
if (p?.type === 'text' && typeof p.text === 'string' && !p.synthetic && !p.ignored) {
|
|
37
|
+
out.push(p.text);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return out.join('\n');
|
|
41
|
+
}
|
|
42
|
+
function messageToEntries(info, parts) {
|
|
43
|
+
if (!info || typeof info.id !== 'string')
|
|
44
|
+
return [];
|
|
45
|
+
const ts = toIso(info?.time?.created);
|
|
46
|
+
if (info.role === 'user') {
|
|
47
|
+
const prompt = joinTextParts(parts);
|
|
48
|
+
if (!prompt)
|
|
49
|
+
return [];
|
|
50
|
+
return [{ kind: 'prompt', prompt, source_uuid: info.id, ...(ts ? { ts } : {}) }];
|
|
51
|
+
}
|
|
52
|
+
if (info.role === 'assistant') {
|
|
53
|
+
const out = [];
|
|
54
|
+
const text = joinTextParts(parts);
|
|
55
|
+
const toolParts = parts.filter((p) => p?.type === 'tool' && typeof p.callID === 'string' && p.callID);
|
|
56
|
+
if (text || toolParts.length) {
|
|
57
|
+
out.push({
|
|
58
|
+
kind: 'assistant',
|
|
59
|
+
text,
|
|
60
|
+
blocks: text ? [{ type: 'text', text }] : [],
|
|
61
|
+
...(typeof info?.tokens?.input === 'number' ? { input_tokens: info.tokens.input } : {}),
|
|
62
|
+
...(typeof info?.tokens?.output === 'number' ? { output_tokens: info.tokens.output } : {}),
|
|
63
|
+
...(typeof info.modelID === 'string' ? { model: info.modelID } : {}),
|
|
64
|
+
...(typeof info.finish === 'string' ? { stop_reason: info.finish } : {}),
|
|
65
|
+
source_uuid: info.id,
|
|
66
|
+
...(ts ? { ts } : {}),
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
for (const p of toolParts) {
|
|
70
|
+
const toolName = typeof p.tool === 'string' && p.tool ? p.tool : 'tool';
|
|
71
|
+
out.push({
|
|
72
|
+
kind: 'tool_use',
|
|
73
|
+
tool_use_id: p.callID,
|
|
74
|
+
tool_name: toolName,
|
|
75
|
+
tool_input: p?.state?.input ?? null,
|
|
76
|
+
source_uuid: p.callID,
|
|
77
|
+
});
|
|
78
|
+
const status = p?.state?.status;
|
|
79
|
+
if (status === 'completed' || status === 'error') {
|
|
80
|
+
out.push({
|
|
81
|
+
kind: 'tool_result',
|
|
82
|
+
tool_use_id: p.callID,
|
|
83
|
+
tool_name: toolName,
|
|
84
|
+
content: status === 'error' ? (p.state.error ?? '') : (p.state.output ?? ''),
|
|
85
|
+
...(status === 'error' ? { is_error: true } : {}),
|
|
86
|
+
source_uuid: `${p.callID}#out`,
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
return out;
|
|
91
|
+
}
|
|
92
|
+
return [];
|
|
93
|
+
}
|
|
94
|
+
/** Parse the plugin-written transcript JSONL and emit every ingest entry that
|
|
95
|
+
* comes *after* the message-id watermark `afterUuid`. Same contract as the
|
|
96
|
+
* claude-code parser. */
|
|
97
|
+
export function parseTranscript(content, afterUuid) {
|
|
98
|
+
const lines = content.split('\n');
|
|
99
|
+
// First pass: locate the watermark message so a rewind/fork (id gone)
|
|
100
|
+
// replays from the top instead of wedging capture.
|
|
101
|
+
let watermarkLine = -1;
|
|
102
|
+
if (afterUuid) {
|
|
103
|
+
for (let i = 0; i < lines.length; i++) {
|
|
104
|
+
const line = lines[i].trim();
|
|
105
|
+
if (!line)
|
|
106
|
+
continue;
|
|
107
|
+
try {
|
|
108
|
+
if (JSON.parse(line)?.info?.id === afterUuid) {
|
|
109
|
+
watermarkLine = i;
|
|
110
|
+
break;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
catch { /* skip unparseable */ }
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
const foundWatermark = afterUuid === null || watermarkLine !== -1;
|
|
117
|
+
const out = [];
|
|
118
|
+
let lastUuid = foundWatermark ? afterUuid : null;
|
|
119
|
+
for (let i = 0; i < lines.length; i++) {
|
|
120
|
+
if (watermarkLine !== -1 && i <= watermarkLine)
|
|
121
|
+
continue;
|
|
122
|
+
const line = lines[i].trim();
|
|
123
|
+
if (!line)
|
|
124
|
+
continue;
|
|
125
|
+
let parsed;
|
|
126
|
+
try {
|
|
127
|
+
parsed = JSON.parse(line);
|
|
128
|
+
}
|
|
129
|
+
catch {
|
|
130
|
+
continue;
|
|
131
|
+
}
|
|
132
|
+
const entries = messageToEntries(parsed?.info, Array.isArray(parsed?.parts) ? parsed.parts : []);
|
|
133
|
+
if (!entries.length)
|
|
134
|
+
continue;
|
|
135
|
+
for (const e of entries)
|
|
136
|
+
out.push(e);
|
|
137
|
+
if (typeof parsed?.info?.id === 'string')
|
|
138
|
+
lastUuid = parsed.info.id;
|
|
139
|
+
}
|
|
140
|
+
return { entries: out, lastUuid, foundWatermark };
|
|
141
|
+
}
|
|
142
|
+
//# sourceMappingURL=opencode.js.map
|
package/dist/commands/agent.js
CHANGED
|
@@ -34,12 +34,12 @@ export const agentCommand = new Command('agent')
|
|
|
34
34
|
}));
|
|
35
35
|
agentCommand
|
|
36
36
|
.command('models')
|
|
37
|
-
.description('List the LLM models an agent can use (ids for `agent create --model` and `agent set model`)')
|
|
37
|
+
.description('List the LLM models an agent can use (ids and tier aliases for `agent create --model` and `agent set model`)')
|
|
38
38
|
.option('--json', 'Output as JSON')
|
|
39
39
|
.action((opts) => run('Models', async () => {
|
|
40
40
|
const res = await get('/agents/models');
|
|
41
41
|
if (opts.json) {
|
|
42
|
-
console.log(JSON.stringify(res.data));
|
|
42
|
+
console.log(JSON.stringify({ models: res.data, aliases: res.aliases ?? {} }));
|
|
43
43
|
return;
|
|
44
44
|
}
|
|
45
45
|
const width = res.data.reduce((m, x) => Math.max(m, x.id.length), 0);
|
|
@@ -56,11 +56,21 @@ agentCommand
|
|
|
56
56
|
notes.push('default');
|
|
57
57
|
console.log(`${m.id.padEnd(width)} ${muted(notes.join(' · '))}`);
|
|
58
58
|
}
|
|
59
|
+
// Tier aliases (older servers don't send them): an id pins that exact
|
|
60
|
+
// model; an alias follows the platform's rotation as new models ship.
|
|
61
|
+
if (res.aliases && Object.keys(res.aliases).length > 0) {
|
|
62
|
+
console.log('');
|
|
63
|
+
console.log('Tier aliases (an agent set to one follows the platform model rotations):');
|
|
64
|
+
const aw = Object.keys(res.aliases).reduce((m, k) => Math.max(m, k.length), 0);
|
|
65
|
+
for (const [alias, id] of Object.entries(res.aliases)) {
|
|
66
|
+
console.log(`${alias.padEnd(aw)} ${muted(`-> ${id}`)}`);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
59
69
|
}));
|
|
60
70
|
agentCommand
|
|
61
71
|
.command('create <name>')
|
|
62
72
|
.description('Create an agent')
|
|
63
|
-
.option('--model <model>', 'Model
|
|
73
|
+
.option('--model <model>', 'Model id (pins that model) or tier alias like gipity-default/opus (follows rotations) - see `gipity agent models`. Default: gipity-default')
|
|
64
74
|
.option('--switch', 'Switch to new agent after creation')
|
|
65
75
|
.option('--json', 'Output as JSON')
|
|
66
76
|
.action((name, opts) => run('Create', async () => {
|
|
@@ -83,7 +93,7 @@ agentCommand
|
|
|
83
93
|
}));
|
|
84
94
|
agentCommand
|
|
85
95
|
.command('set <field> <value>')
|
|
86
|
-
.description('Set a field (model, temp). Model ids: `gipity agent models`')
|
|
96
|
+
.description('Set a field (model, temp). Model ids + tier aliases: `gipity agent models`')
|
|
87
97
|
.option('--json', 'Output as JSON')
|
|
88
98
|
.action((field, value, opts) => run('Set', async () => {
|
|
89
99
|
const config = requireConfig();
|
package/dist/commands/build.js
CHANGED
|
@@ -1127,6 +1127,14 @@ async function launchNonClaudeAgent(adapter, ctx) {
|
|
|
1127
1127
|
console.log('');
|
|
1128
1128
|
}
|
|
1129
1129
|
// ── Spawn ───────────────────────────────────────────────────────────────
|
|
1130
|
+
// Async pre-spawn setup (e.g. opencode's model-slot token mint). Best-effort:
|
|
1131
|
+
// the agent must still launch when offline or logged out.
|
|
1132
|
+
if (adapter.prepareLaunch) {
|
|
1133
|
+
try {
|
|
1134
|
+
await adapter.prepareLaunch();
|
|
1135
|
+
}
|
|
1136
|
+
catch { /* never block the launch */ }
|
|
1137
|
+
}
|
|
1130
1138
|
const childEnv = { ...process.env };
|
|
1131
1139
|
if (convGuid)
|
|
1132
1140
|
childEnv.GIPITY_CONVERSATION_GUID = convGuid;
|
|
@@ -428,18 +428,24 @@ default; pass --model <id> only if you want a specific one (see the catalog with
|
|
|
428
428
|
|
|
429
429
|
Tips:
|
|
430
430
|
- Describe genre, mood, instruments, and tempo (e.g. "upbeat lo-fi hip hop with mellow piano")
|
|
431
|
-
- Music is instrumental by default; pass --vocals to allow singing
|
|
431
|
+
- Music is instrumental by default; pass --vocals to allow singing, or --lyrics /
|
|
432
|
+
--lyrics-file to have the vocalist sing YOUR exact words (section tags like
|
|
433
|
+
[Verse] / [Chorus] are understood; keep the prompt to style only)
|
|
434
|
+
- With lyrics, size --duration to the words (roughly 10s per short section)
|
|
432
435
|
- Longer clips cost more; the max length depends on the model
|
|
433
436
|
|
|
434
437
|
Examples:
|
|
435
438
|
gipity generate music "chill lo-fi beat for studying"
|
|
436
439
|
gipity generate music "epic orchestral battle theme" --duration 60 -o src/assets/audio/theme.mp3
|
|
437
440
|
gipity generate music "indie pop chorus" --vocals --duration 20
|
|
441
|
+
gipity generate music "80s synth-pop, female vocals" --lyrics-file lyrics.txt --duration 120 -o song.mp3
|
|
438
442
|
`)
|
|
439
443
|
.argument('<prompt>', 'Text description of the music to generate')
|
|
440
444
|
.option('--duration <seconds>', 'Clip length in seconds (default 30; max depends on the model)', (v) => parseInt(v, 10))
|
|
441
445
|
.option('--model <model>', 'Music model id (default: platform default; list ids: gipity service call music/models --get)')
|
|
442
446
|
.option('--vocals', 'Allow vocals (default: instrumental only)')
|
|
447
|
+
.option('--lyrics <text>', 'Exact lyrics to sing (implies vocals; only lyrics-capable models)')
|
|
448
|
+
.option('--lyrics-file <file>', 'Read the exact lyrics to sing from a file (implies vocals)')
|
|
443
449
|
.option('-o, --output <file>', 'Output path (default ./music.mp3). For audio your app ships, write it into the source tree so it deploys, e.g. -o src/assets/audio/theme.mp3; the cwd default is fine for one-off generation.')
|
|
444
450
|
.option('--json', 'Output as JSON')
|
|
445
451
|
.action(async (prompt, opts) => {
|
|
@@ -447,11 +453,20 @@ Examples:
|
|
|
447
453
|
const { config } = await resolveProjectContext();
|
|
448
454
|
if (opts.output)
|
|
449
455
|
ensureOutputDir(opts.output);
|
|
456
|
+
if (opts.lyrics && opts.lyricsFile) {
|
|
457
|
+
console.error(clrError('Pass --lyrics or --lyrics-file, not both.'));
|
|
458
|
+
process.exit(1);
|
|
459
|
+
}
|
|
460
|
+
const lyrics = opts.lyricsFile
|
|
461
|
+
? readFileSync(opts.lyricsFile, 'utf8').trim()
|
|
462
|
+
: opts.lyrics;
|
|
450
463
|
const doGenerate = () => post(`/projects/${config.projectGuid}/generate/music`, {
|
|
451
464
|
prompt,
|
|
452
465
|
duration_seconds: opts.duration,
|
|
453
466
|
model: opts.model,
|
|
454
|
-
instrumental
|
|
467
|
+
// Lyrics imply vocals; otherwise instrumental unless --vocals.
|
|
468
|
+
instrumental: lyrics ? false : !opts.vocals,
|
|
469
|
+
lyrics: lyrics || undefined,
|
|
455
470
|
});
|
|
456
471
|
const started = Date.now();
|
|
457
472
|
const result = opts.json
|