@sage-protocol/cli 0.4.0 → 0.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/dist/cli/browser-wallet-integration.js +0 -1
- package/dist/cli/cast-wallet-manager.js +0 -1
- package/dist/cli/commands/interview.js +149 -0
- package/dist/cli/commands/personal.js +138 -79
- package/dist/cli/commands/prompts.js +242 -87
- package/dist/cli/commands/stake-status.js +0 -2
- package/dist/cli/config.js +28 -8
- package/dist/cli/governance-manager.js +28 -19
- package/dist/cli/index.js +32 -8
- package/dist/cli/library-manager.js +16 -6
- package/dist/cli/mcp-server-stdio.js +759 -156
- package/dist/cli/mcp-server.js +4 -30
- package/dist/cli/metamask-integration.js +0 -1
- package/dist/cli/privy-wallet-manager.js +2 -2
- package/dist/cli/prompt-manager.js +0 -1
- package/dist/cli/services/artifact-manager.js +198 -0
- package/dist/cli/services/doctor/fixers.js +1 -1
- package/dist/cli/services/mcp/env-loader.js +2 -0
- package/dist/cli/services/mcp/prompt-result-formatter.js +8 -1
- package/dist/cli/services/mcp/quick-start.js +14 -15
- package/dist/cli/services/mcp/sage-tool-registry.js +322 -0
- package/dist/cli/services/mcp/tool-args-validator.js +43 -0
- package/dist/cli/services/metaprompt/anthropic-client.js +87 -0
- package/dist/cli/services/metaprompt/interview-driver.js +161 -0
- package/dist/cli/services/metaprompt/model-client.js +49 -0
- package/dist/cli/services/metaprompt/openai-client.js +67 -0
- package/dist/cli/services/metaprompt/persistence.js +86 -0
- package/dist/cli/services/metaprompt/prompt-builder.js +186 -0
- package/dist/cli/services/metaprompt/session.js +18 -80
- package/dist/cli/services/metaprompt/slot-planner.js +115 -0
- package/dist/cli/services/metaprompt/templates.json +130 -0
- package/dist/cli/services/project-context.js +98 -0
- package/dist/cli/subdao.js +0 -3
- package/dist/cli/sxxx-manager.js +0 -1
- package/dist/cli/utils/aliases.js +0 -6
- package/dist/cli/utils/tx-wait.js +0 -3
- package/dist/cli/wallet-manager.js +18 -19
- package/dist/cli/walletconnect-integration.js +0 -1
- package/dist/cli/wizard-manager.js +0 -1
- package/package.json +3 -1
- package/dist/cli/commands/prompt-test.js +0 -176
- package/dist/cli/commands/prompt.js +0 -2531
package/dist/cli/index.js
CHANGED
|
@@ -1,7 +1,23 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
+
// Filter out deprecated Lit SDK warning immediately
|
|
4
|
+
const realStderrWrite = process.stderr.write.bind(process.stderr);
|
|
5
|
+
process.stderr.write = (chunk, encoding, callback) => {
|
|
6
|
+
if (chunk && chunk.toString().includes('LitErrorKind is deprecated')) {
|
|
7
|
+
if (typeof callback === 'function') callback();
|
|
8
|
+
return true;
|
|
9
|
+
}
|
|
10
|
+
return realStderrWrite(chunk, encoding, callback);
|
|
11
|
+
};
|
|
12
|
+
|
|
3
13
|
const path = require('path');
|
|
4
14
|
const { Command } = require('commander');
|
|
15
|
+
|
|
16
|
+
// Pre-detect JSON mode so setup logs don't pollute machine-readable output
|
|
17
|
+
if (process.argv.includes('--json')) {
|
|
18
|
+
process.env.SAGE_QUIET_JSON = process.env.SAGE_QUIET_JSON || '1';
|
|
19
|
+
}
|
|
20
|
+
|
|
5
21
|
// Prefer shared config manager via workspace package; fallback to local if unavailable
|
|
6
22
|
let config;
|
|
7
23
|
try {
|
|
@@ -67,7 +83,6 @@ if (isVerbose) process.env.SAGE_VERBOSE = '1';
|
|
|
67
83
|
// Global session/save-context
|
|
68
84
|
if (process.argv.includes('--session')) process.env.SAGE_SESSION = '1';
|
|
69
85
|
if (process.argv.includes('--save-context')) process.env.SAGE_SAVE_CONTEXT = '1';
|
|
70
|
-
if (process.argv.includes('--verbose')) process.env.SAGE_VERBOSE = '1';
|
|
71
86
|
if (process.argv.includes('--force')) process.env.SAGE_FORCE = '1';
|
|
72
87
|
if (process.argv.includes('--private')) process.env.SAGE_USE_PRIVATE_TX = '1';
|
|
73
88
|
|
|
@@ -86,7 +101,7 @@ program
|
|
|
86
101
|
|
|
87
102
|
// Reordered to highlight consolidated namespaces ('prompts' and 'gov')
|
|
88
103
|
const commandGroups = [
|
|
89
|
-
{ title: 'Content (new)', modules: ['prompts', 'project', '
|
|
104
|
+
{ title: 'Content (new)', modules: ['prompts', 'project', 'personal', 'interview', 'creator', 'contributor', 'bounty'] },
|
|
90
105
|
{ title: 'Governance (new)', modules: ['proposals', 'governance', 'dao', 'timelock', 'roles', 'members', 'gov-config', 'stake-status'] },
|
|
91
106
|
{ title: 'Treasury', modules: ['treasury', 'safe', 'boost'] },
|
|
92
107
|
{ title: 'Ops & Utilities', modules: ['config', 'wallet', 'sxxx', 'ipfs', 'ipns', 'context', 'doctor', 'factory', 'upgrade', 'resolve', 'dry-run-queue', 'mcp', 'start', 'wizard', 'init', 'dao-config', 'pin', 'council', 'sbt', 'completion', 'help', 'hook'] },
|
|
@@ -147,7 +162,8 @@ const additionalModules = [
|
|
|
147
162
|
'start',
|
|
148
163
|
'completion',
|
|
149
164
|
'help',
|
|
150
|
-
'hook'
|
|
165
|
+
'hook',
|
|
166
|
+
'interview'
|
|
151
167
|
];
|
|
152
168
|
additionalModules.forEach((mod) => moduleSet.add(mod));
|
|
153
169
|
|
|
@@ -171,12 +187,19 @@ program.configureOutput({
|
|
|
171
187
|
}
|
|
172
188
|
});
|
|
173
189
|
|
|
174
|
-
|
|
175
|
-
|
|
190
|
+
// Alias support wrapper
|
|
191
|
+
const currentStderrWrite = process.stderr.write.bind(process.stderr);
|
|
192
|
+
aliasSupport.setStderrWriter(currentStderrWrite);
|
|
176
193
|
process.stderr.write = (chunk, encoding, callback) => {
|
|
194
|
+
// Check filter again just in case aliasSupport bypassed it (unlikely if chained correctly)
|
|
195
|
+
if (chunk && chunk.toString().includes('LitErrorKind is deprecated')) {
|
|
196
|
+
if (typeof callback === 'function') callback();
|
|
197
|
+
return true;
|
|
198
|
+
}
|
|
199
|
+
|
|
177
200
|
const handled = aliasSupport.handleOutputError(chunk);
|
|
178
201
|
if (!handled) {
|
|
179
|
-
return
|
|
202
|
+
return currentStderrWrite(chunk, encoding, callback);
|
|
180
203
|
}
|
|
181
204
|
if (typeof callback === 'function') callback();
|
|
182
205
|
return true;
|
|
@@ -194,8 +217,9 @@ program.parse(normalizedArgv);
|
|
|
194
217
|
|
|
195
218
|
// Handle clean exit
|
|
196
219
|
process.on('exit', () => {
|
|
197
|
-
|
|
198
|
-
|
|
220
|
+
// Restore original writer on exit
|
|
221
|
+
process.stderr.write = realStderrWrite;
|
|
222
|
+
aliasSupport.setStderrWriter(realStderrWrite);
|
|
199
223
|
if (global.walletManager) {
|
|
200
224
|
global.walletManager.disconnect().catch(() => { });
|
|
201
225
|
}
|
|
@@ -2,7 +2,6 @@ const fs = require('fs');
|
|
|
2
2
|
const path = require('path');
|
|
3
3
|
const axios = require('axios');
|
|
4
4
|
const { resolveArtifact } = require('./utils/artifacts');
|
|
5
|
-
try { require('dotenv').config({ quiet: true }); } catch (_) {}
|
|
6
5
|
const { ethers } = require('ethers');
|
|
7
6
|
const WalletManager = require('./wallet-manager');
|
|
8
7
|
const cliConfig = require('./config');
|
|
@@ -63,6 +62,17 @@ class LibraryManager {
|
|
|
63
62
|
return ensureLibrariesDir({ config: cliConfig });
|
|
64
63
|
}
|
|
65
64
|
|
|
65
|
+
getManifestPath(cid) {
|
|
66
|
+
const dir = this.ensureLibrariesDir();
|
|
67
|
+
return path.join(dir, `${cid}.json`);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
writeManifest(cid, manifest) {
|
|
71
|
+
const manifestPath = this.getManifestPath(cid);
|
|
72
|
+
fs.writeFileSync(manifestPath, JSON.stringify(manifest, null, 2));
|
|
73
|
+
return manifestPath;
|
|
74
|
+
}
|
|
75
|
+
|
|
66
76
|
listPinned() {
|
|
67
77
|
return listPinnedManifests({ config: cliConfig });
|
|
68
78
|
}
|
|
@@ -105,8 +115,7 @@ class LibraryManager {
|
|
|
105
115
|
prompts: [],
|
|
106
116
|
};
|
|
107
117
|
|
|
108
|
-
const manifestPath =
|
|
109
|
-
fs.writeFileSync(manifestPath, JSON.stringify(manifest, null, 2));
|
|
118
|
+
const manifestPath = this.writeManifest(cid, manifest);
|
|
110
119
|
|
|
111
120
|
return { cid, path: manifestPath, manifest };
|
|
112
121
|
}
|
|
@@ -152,8 +161,7 @@ class LibraryManager {
|
|
|
152
161
|
manifest.prompts = [];
|
|
153
162
|
}
|
|
154
163
|
|
|
155
|
-
const manifestPath =
|
|
156
|
-
fs.writeFileSync(manifestPath, JSON.stringify(manifest, null, 2));
|
|
164
|
+
const manifestPath = this.writeManifest(cid, manifest);
|
|
157
165
|
|
|
158
166
|
return { cid, path: manifestPath };
|
|
159
167
|
}
|
|
@@ -707,7 +715,9 @@ class LibraryManager {
|
|
|
707
715
|
|
|
708
716
|
// Resolve governor and contract
|
|
709
717
|
const gov = await this.getGovernorAddress();
|
|
710
|
-
|
|
718
|
+
if (process.env.SAGE_VERBOSE === '1' && String(process.env.SAGE_QUIET_JSON || '').trim() !== '1') {
|
|
719
|
+
console.log(`🔍 Debug: Executing proposal ${proposalId} on governor ${gov}`);
|
|
720
|
+
}
|
|
711
721
|
const GovABI = resolveArtifact('contracts/cloneable/PromptGovernorCloneable.sol/PromptGovernorCloneable.json').abi;
|
|
712
722
|
const governorConnector = createGovernorConnector({ ethersLib: ethers });
|
|
713
723
|
const governor = governorConnector.connect({ address: gov, abi: GovABI, signerOrProvider: signer });
|