@sage-protocol/cli 0.3.0 → 0.3.3
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/commands/doctor.js +87 -8
- package/dist/cli/commands/gov-config.js +81 -0
- package/dist/cli/commands/governance.js +152 -72
- package/dist/cli/commands/library.js +9 -0
- package/dist/cli/commands/proposals.js +187 -17
- package/dist/cli/commands/skills.js +175 -21
- package/dist/cli/commands/subdao.js +22 -2
- package/dist/cli/config/playbooks.json +15 -0
- package/dist/cli/governance-manager.js +25 -4
- package/dist/cli/index.js +5 -6
- package/dist/cli/library-manager.js +79 -0
- package/dist/cli/mcp-server-stdio.js +1655 -82
- package/dist/cli/schemas/manifest.schema.json +55 -0
- package/dist/cli/services/doctor/fixers.js +134 -0
- package/dist/cli/services/mcp/bulk-operations.js +272 -0
- package/dist/cli/services/mcp/dependency-analyzer.js +202 -0
- package/dist/cli/services/mcp/library-listing.js +2 -2
- package/dist/cli/services/mcp/local-prompt-collector.js +1 -0
- package/dist/cli/services/mcp/manifest-downloader.js +5 -3
- package/dist/cli/services/mcp/manifest-fetcher.js +17 -1
- package/dist/cli/services/mcp/manifest-workflows.js +127 -15
- package/dist/cli/services/mcp/quick-start.js +287 -0
- package/dist/cli/services/mcp/stdio-runner.js +30 -5
- package/dist/cli/services/mcp/template-manager.js +156 -0
- package/dist/cli/services/mcp/templates/default-templates.json +84 -0
- package/dist/cli/services/mcp/tool-args-validator.js +66 -0
- package/dist/cli/services/mcp/trending-formatter.js +1 -1
- package/dist/cli/services/mcp/unified-prompt-search.js +2 -2
- package/dist/cli/services/metaprompt/designer.js +12 -5
- package/dist/cli/services/subdao/applier.js +208 -196
- package/dist/cli/services/subdao/planner.js +41 -6
- package/dist/cli/subdao-manager.js +14 -0
- package/dist/cli/utils/aliases.js +17 -2
- package/dist/cli/utils/contract-error-decoder.js +61 -0
- package/dist/cli/utils/suggestions.js +17 -12
- package/package.json +3 -2
- package/src/schemas/manifest.schema.json +55 -0
package/dist/cli/index.js
CHANGED
|
@@ -42,7 +42,7 @@ try {
|
|
|
42
42
|
};
|
|
43
43
|
const getArg = (name) => {
|
|
44
44
|
const i = process.argv.indexOf(name);
|
|
45
|
-
return i >= 0 && process.argv[i+1] && !process.argv[i+1].startsWith('-') ? process.argv[i+1] : null;
|
|
45
|
+
return i >= 0 && process.argv[i + 1] && !process.argv[i + 1].startsWith('-') ? process.argv[i + 1] : null;
|
|
46
46
|
};
|
|
47
47
|
const netArg = getArg('--net') || process.env.SAGE_NET || null;
|
|
48
48
|
if (netArg) {
|
|
@@ -89,7 +89,7 @@ const commandGroups = [
|
|
|
89
89
|
{ title: 'Content (new)', modules: ['skills', 'prompts', 'prompt', 'library', 'premium', 'premium-pre', 'creator', 'contributor', 'bounty'] },
|
|
90
90
|
{ title: 'Governance (new)', modules: ['proposals', 'governance', 'subdao', 'timelock', 'roles', 'members', 'gov-config', 'stake-status'] },
|
|
91
91
|
{ title: 'Treasury', modules: ['treasury', 'safe', 'boost'] },
|
|
92
|
-
{ title: 'Ops & Utilities', modules: ['config', 'wallet', 'sxxx', 'ipfs', 'ipns', 'context', 'doctor', 'factory', 'upgrade', 'resolve', 'dry-run-queue', 'mcp', 'start', 'wizard', 'init', 'subdao-config', 'pin', 'council', 'sbt', 'completion', 'help', 'hook'
|
|
92
|
+
{ title: 'Ops & Utilities', modules: ['config', 'wallet', 'sxxx', 'ipfs', 'ipns', 'context', 'doctor', 'factory', 'upgrade', 'resolve', 'dry-run-queue', 'mcp', 'start', 'wizard', 'init', 'subdao-config', 'pin', 'council', 'sbt', 'completion', 'help', 'hook'] },
|
|
93
93
|
{ title: 'Developer', modules: ['dev', 'registry'] }
|
|
94
94
|
];
|
|
95
95
|
|
|
@@ -116,7 +116,7 @@ program.addHelpText('beforeAll', () => {
|
|
|
116
116
|
if (!hasProjectConfig && !hasWorkspace) {
|
|
117
117
|
firstRun = '\nTip: first time here? Try:\n - sage wizard\n - or: sage ipfs setup && sage prompts init\n';
|
|
118
118
|
}
|
|
119
|
-
} catch (_) {}
|
|
119
|
+
} catch (_) { }
|
|
120
120
|
return `Top workflows: ${highlights}\n${lines}\n${note}${firstRun}\n`;
|
|
121
121
|
});
|
|
122
122
|
|
|
@@ -148,7 +148,6 @@ const additionalModules = [
|
|
|
148
148
|
'completion',
|
|
149
149
|
'help',
|
|
150
150
|
'hook'
|
|
151
|
-
, 'ipns'
|
|
152
151
|
];
|
|
153
152
|
additionalModules.forEach((mod) => moduleSet.add(mod));
|
|
154
153
|
|
|
@@ -168,7 +167,7 @@ if (cliTestMode) {
|
|
|
168
167
|
|
|
169
168
|
program.configureOutput({
|
|
170
169
|
writeOut: (str) => process.stdout.write(str),
|
|
171
|
-
writeErr: () => {},
|
|
170
|
+
writeErr: () => { },
|
|
172
171
|
outputError: (str, write) => {
|
|
173
172
|
if (!aliasSupport.handleOutputError(str)) {
|
|
174
173
|
write(str);
|
|
@@ -202,7 +201,7 @@ process.on('exit', () => {
|
|
|
202
201
|
process.stderr.write = originalStderrWrite;
|
|
203
202
|
aliasSupport.setStderrWriter(originalStderrWrite);
|
|
204
203
|
if (global.walletManager) {
|
|
205
|
-
global.walletManager.disconnect().catch(() => {});
|
|
204
|
+
global.walletManager.disconnect().catch(() => { });
|
|
206
205
|
}
|
|
207
206
|
});
|
|
208
207
|
|
|
@@ -79,6 +79,85 @@ class LibraryManager {
|
|
|
79
79
|
return searchLocalManifests({ config: cliConfig, query });
|
|
80
80
|
}
|
|
81
81
|
|
|
82
|
+
/**
|
|
83
|
+
* Create a new local library manifest in the pinned libraries directory.
|
|
84
|
+
* This is used by MCP quick-start flows for "My Library" and ad-hoc libraries.
|
|
85
|
+
* Returns a pseudo-CID (local_*) that can be used with the local manifest loader.
|
|
86
|
+
*/
|
|
87
|
+
createLibrary(name, description = '', options = {}) {
|
|
88
|
+
const dir = this.ensureLibrariesDir();
|
|
89
|
+
const baseName = String(name || 'Library').trim() || 'Library';
|
|
90
|
+
const slugBase = baseName.toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-+|-+$/g, '') || 'library';
|
|
91
|
+
let cid = `local_${slugBase}`;
|
|
92
|
+
let suffix = 1;
|
|
93
|
+
// Ensure uniqueness within the libraries dir
|
|
94
|
+
while (fs.existsSync(path.join(dir, `${cid}.json`))) {
|
|
95
|
+
cid = `local_${slugBase}_${suffix++}`;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
const manifest = {
|
|
99
|
+
version: 2,
|
|
100
|
+
library: {
|
|
101
|
+
name: baseName,
|
|
102
|
+
description: String(description || ''),
|
|
103
|
+
...(options.metadata || {}),
|
|
104
|
+
},
|
|
105
|
+
prompts: [],
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
const manifestPath = path.join(dir, `${cid}.json`);
|
|
109
|
+
fs.writeFileSync(manifestPath, JSON.stringify(manifest, null, 2));
|
|
110
|
+
|
|
111
|
+
return { cid, path: manifestPath, manifest };
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Pin (or re-pin) a manifest into the local libraries directory.
|
|
116
|
+
* Accepts either a manifest object or { manifestPath, manifestData } from callers.
|
|
117
|
+
* Returns { cid, path } where cid may be provided or auto-assigned as local_*.
|
|
118
|
+
*/
|
|
119
|
+
pinLibrary(manifestOrOptions) {
|
|
120
|
+
const dir = this.ensureLibrariesDir();
|
|
121
|
+
let manifest = manifestOrOptions;
|
|
122
|
+
|
|
123
|
+
// Support callers that pass { manifestPath, manifestData }
|
|
124
|
+
if (manifestOrOptions && typeof manifestOrOptions === 'object' && (manifestOrOptions.manifest || manifestOrOptions.manifestData)) {
|
|
125
|
+
manifest = manifestOrOptions.manifest || manifestOrOptions.manifestData;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
if (!manifest || typeof manifest !== 'object') {
|
|
129
|
+
throw new Error('pinLibrary requires a manifest object');
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
const libName = String(manifest.library?.name || 'Library').trim() || 'Library';
|
|
133
|
+
const slugBase = libName.toLowerCase().replace(/[^a-z0-9]+/g, '-').replace(/^-+|-+$/g, '') || 'library';
|
|
134
|
+
|
|
135
|
+
let cid = manifest.cid || manifest.library?.cid || null;
|
|
136
|
+
if (!cid) {
|
|
137
|
+
cid = `local_${slugBase}`;
|
|
138
|
+
let suffix = 1;
|
|
139
|
+
while (fs.existsSync(path.join(dir, `${cid}.json`))) {
|
|
140
|
+
cid = `local_${slugBase}_${suffix++}`;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// Ensure manifest has expected top-level fields
|
|
145
|
+
if (!manifest.version) {
|
|
146
|
+
manifest.version = 2;
|
|
147
|
+
}
|
|
148
|
+
if (!manifest.library) {
|
|
149
|
+
manifest.library = { name: libName };
|
|
150
|
+
}
|
|
151
|
+
if (!Array.isArray(manifest.prompts)) {
|
|
152
|
+
manifest.prompts = [];
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
const manifestPath = path.join(dir, `${cid}.json`);
|
|
156
|
+
fs.writeFileSync(manifestPath, JSON.stringify(manifest, null, 2));
|
|
157
|
+
|
|
158
|
+
return { cid, path: manifestPath };
|
|
159
|
+
}
|
|
160
|
+
|
|
82
161
|
// Compute CID locally from bytes using ipfs-only-hash (UnixFS DAG-PB, CIDv0 by default)
|
|
83
162
|
// Compute CID locally from bytes using ipfs-only-hash (UnixFS DAG-PB, CIDv0 by default)
|
|
84
163
|
async _computeCidFromBuffer(buffer) {
|