cognitive-modules 0.6.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/README.md +165 -0
- package/dist/cli.d.ts +16 -0
- package/dist/cli.js +335 -0
- package/dist/commands/add.d.ts +34 -0
- package/dist/commands/add.js +229 -0
- package/dist/commands/index.d.ts +11 -0
- package/dist/commands/index.js +11 -0
- package/dist/commands/init.d.ts +5 -0
- package/dist/commands/init.js +78 -0
- package/dist/commands/list.d.ts +5 -0
- package/dist/commands/list.js +28 -0
- package/dist/commands/pipe.d.ts +9 -0
- package/dist/commands/pipe.js +59 -0
- package/dist/commands/remove.d.ts +10 -0
- package/dist/commands/remove.js +47 -0
- package/dist/commands/run.d.ts +12 -0
- package/dist/commands/run.js +65 -0
- package/dist/commands/update.d.ts +14 -0
- package/dist/commands/update.js +105 -0
- package/dist/commands/versions.d.ts +13 -0
- package/dist/commands/versions.js +60 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +11 -0
- package/dist/modules/index.d.ts +5 -0
- package/dist/modules/index.js +5 -0
- package/dist/modules/loader.d.ts +12 -0
- package/dist/modules/loader.js +197 -0
- package/dist/modules/runner.d.ts +12 -0
- package/dist/modules/runner.js +229 -0
- package/dist/providers/anthropic.d.ts +14 -0
- package/dist/providers/anthropic.js +70 -0
- package/dist/providers/base.d.ts +11 -0
- package/dist/providers/base.js +19 -0
- package/dist/providers/deepseek.d.ts +14 -0
- package/dist/providers/deepseek.js +66 -0
- package/dist/providers/gemini.d.ts +19 -0
- package/dist/providers/gemini.js +94 -0
- package/dist/providers/index.d.ts +19 -0
- package/dist/providers/index.js +74 -0
- package/dist/providers/minimax.d.ts +14 -0
- package/dist/providers/minimax.js +64 -0
- package/dist/providers/moonshot.d.ts +14 -0
- package/dist/providers/moonshot.js +65 -0
- package/dist/providers/ollama.d.ts +13 -0
- package/dist/providers/ollama.js +64 -0
- package/dist/providers/openai.d.ts +14 -0
- package/dist/providers/openai.js +67 -0
- package/dist/providers/qwen.d.ts +14 -0
- package/dist/providers/qwen.js +65 -0
- package/dist/types.d.ts +136 -0
- package/dist/types.js +5 -0
- package/package.json +48 -0
- package/src/cli.ts +375 -0
- package/src/commands/add.ts +315 -0
- package/src/commands/index.ts +12 -0
- package/src/commands/init.ts +94 -0
- package/src/commands/list.ts +33 -0
- package/src/commands/pipe.ts +76 -0
- package/src/commands/remove.ts +57 -0
- package/src/commands/run.ts +80 -0
- package/src/commands/update.ts +130 -0
- package/src/commands/versions.ts +79 -0
- package/src/index.ts +44 -0
- package/src/modules/index.ts +6 -0
- package/src/modules/loader.ts +219 -0
- package/src/modules/runner.ts +278 -0
- package/src/providers/anthropic.ts +89 -0
- package/src/providers/base.ts +29 -0
- package/src/providers/deepseek.ts +83 -0
- package/src/providers/gemini.ts +117 -0
- package/src/providers/index.ts +78 -0
- package/src/providers/minimax.ts +81 -0
- package/src/providers/moonshot.ts +82 -0
- package/src/providers/ollama.ts +83 -0
- package/src/providers/openai.ts +84 -0
- package/src/providers/qwen.ts +82 -0
- package/src/types.ts +184 -0
- package/tsconfig.json +17 -0
package/README.md
ADDED
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
# Cognitive Runtime
|
|
2
|
+
|
|
3
|
+
**Structured AI Task Execution**
|
|
4
|
+
|
|
5
|
+
Cognitive Runtime is the next-generation execution engine for Cognitive Modules. It provides a clean, provider-agnostic runtime that treats LLMs as interchangeable backends.
|
|
6
|
+
|
|
7
|
+
## Philosophy
|
|
8
|
+
|
|
9
|
+
Following the **Cognitive Runtime + Provider** architecture:
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
┌─────────────────────────────────────┐
|
|
13
|
+
│ Cognitive Runtime │
|
|
14
|
+
│ ┌────────────────────────────────┐ │
|
|
15
|
+
│ │ Module System │ │
|
|
16
|
+
│ │ (load, parse, validate) │ │
|
|
17
|
+
│ └────────────────────────────────┘ │
|
|
18
|
+
│ ┌────────────────────────────────┐ │
|
|
19
|
+
│ │ Execution Engine │ │
|
|
20
|
+
│ │ (prompt, schema, contract) │ │
|
|
21
|
+
│ └────────────────────────────────┘ │
|
|
22
|
+
│ ┌────────────────────────────────┐ │
|
|
23
|
+
│ │ Provider Abstraction │ │
|
|
24
|
+
│ │ (gemini, openai, anthropic, │ │
|
|
25
|
+
│ │ deepseek, minimax, qwen...) │ │
|
|
26
|
+
│ └────────────────────────────────┘ │
|
|
27
|
+
└─────────────────────────────────────┘
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Installation
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
npm install -g cognitive-runtime
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Or run directly:
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
npx cognitive-runtime --help
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## Usage
|
|
43
|
+
|
|
44
|
+
### Run a Module
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
cog run code-reviewer --args "def foo(): pass"
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### List Modules
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
cog list
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
### Pipe Mode (stdin/stdout)
|
|
57
|
+
|
|
58
|
+
```bash
|
|
59
|
+
echo "review this code" | cog pipe --module code-reviewer
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### Check Configuration
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
cog doctor
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## Module Formats
|
|
69
|
+
|
|
70
|
+
### v2 (Recommended)
|
|
71
|
+
|
|
72
|
+
```
|
|
73
|
+
my-module/
|
|
74
|
+
├── module.yaml # Machine-readable manifest
|
|
75
|
+
├── prompt.md # Human-readable prompt
|
|
76
|
+
├── schema.json # IO contract
|
|
77
|
+
└── tests/
|
|
78
|
+
├── case1.input.json
|
|
79
|
+
└── case1.expected.json
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
**module.yaml**:
|
|
83
|
+
```yaml
|
|
84
|
+
name: my-module
|
|
85
|
+
version: 2.0.0
|
|
86
|
+
responsibility: What this module does
|
|
87
|
+
constraints:
|
|
88
|
+
no_network: true
|
|
89
|
+
no_side_effects: true
|
|
90
|
+
output:
|
|
91
|
+
mode: json_strict
|
|
92
|
+
require_confidence: true
|
|
93
|
+
require_rationale: true
|
|
94
|
+
require_behavior_equivalence: true
|
|
95
|
+
tools:
|
|
96
|
+
allowed: []
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### v1 (Legacy, still supported)
|
|
100
|
+
|
|
101
|
+
```
|
|
102
|
+
my-module/
|
|
103
|
+
├── MODULE.md # Frontmatter + prompt combined
|
|
104
|
+
└── schema.json
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
## Providers
|
|
108
|
+
|
|
109
|
+
| Provider | Environment Variable | Default Model |
|
|
110
|
+
|------------|------------------------|----------------------|
|
|
111
|
+
| Gemini | `GEMINI_API_KEY` | `gemini-3-flash` |
|
|
112
|
+
| OpenAI | `OPENAI_API_KEY` | `gpt-5.2` |
|
|
113
|
+
| Anthropic | `ANTHROPIC_API_KEY` | `claude-sonnet-4.5` |
|
|
114
|
+
| DeepSeek | `DEEPSEEK_API_KEY` | `deepseek-v3.2` |
|
|
115
|
+
| MiniMax | `MINIMAX_API_KEY` | `MiniMax-M2.1` |
|
|
116
|
+
| Moonshot | `MOONSHOT_API_KEY` | `kimi-k2.5` |
|
|
117
|
+
| Qwen | `DASHSCOPE_API_KEY` | `qwen3-max` |
|
|
118
|
+
| Ollama | `OLLAMA_HOST` | `llama4` (local) |
|
|
119
|
+
|
|
120
|
+
### Provider Aliases
|
|
121
|
+
|
|
122
|
+
- `kimi` → Moonshot
|
|
123
|
+
- `tongyi` / `dashscope` → Qwen
|
|
124
|
+
- `local` → Ollama
|
|
125
|
+
|
|
126
|
+
## Module Search Paths
|
|
127
|
+
|
|
128
|
+
Modules are searched in order:
|
|
129
|
+
|
|
130
|
+
1. `./cognitive/modules/` (project-local)
|
|
131
|
+
2. `./.cognitive/modules/` (project-local, hidden)
|
|
132
|
+
3. `~/.cognitive/modules/` (user-global)
|
|
133
|
+
|
|
134
|
+
## Programmatic API
|
|
135
|
+
|
|
136
|
+
```typescript
|
|
137
|
+
import { getProvider, findModule, runModule } from 'cognitive-runtime';
|
|
138
|
+
|
|
139
|
+
const provider = getProvider('gemini');
|
|
140
|
+
const module = await findModule('code-reviewer', ['./cognitive/modules']);
|
|
141
|
+
|
|
142
|
+
if (module) {
|
|
143
|
+
const result = await runModule(module, provider, {
|
|
144
|
+
args: 'def foo(): pass',
|
|
145
|
+
});
|
|
146
|
+
console.log(result.output);
|
|
147
|
+
}
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
## Development
|
|
151
|
+
|
|
152
|
+
```bash
|
|
153
|
+
# Install dependencies
|
|
154
|
+
npm install
|
|
155
|
+
|
|
156
|
+
# Build
|
|
157
|
+
npm run build
|
|
158
|
+
|
|
159
|
+
# Run in development
|
|
160
|
+
npm run dev -- run code-reviewer --args "..."
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
## License
|
|
164
|
+
|
|
165
|
+
MIT
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Cognitive Modules CLI
|
|
4
|
+
*
|
|
5
|
+
* cog run <module> --args "..." - Run a module
|
|
6
|
+
* cog add <url> -m <name> - Add module from GitHub
|
|
7
|
+
* cog update <module> - Update to latest version
|
|
8
|
+
* cog remove <module> - Remove installed module
|
|
9
|
+
* cog versions <url> - List available versions
|
|
10
|
+
* cog list - List available modules
|
|
11
|
+
* cog pipe --module <name> - Pipe mode (stdin/stdout)
|
|
12
|
+
* cog doctor - Check configuration
|
|
13
|
+
*
|
|
14
|
+
* npx cognitive-modules add ziel-io/cognitive-modules -m code-simplifier
|
|
15
|
+
*/
|
|
16
|
+
export {};
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,335 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* Cognitive Modules CLI
|
|
4
|
+
*
|
|
5
|
+
* cog run <module> --args "..." - Run a module
|
|
6
|
+
* cog add <url> -m <name> - Add module from GitHub
|
|
7
|
+
* cog update <module> - Update to latest version
|
|
8
|
+
* cog remove <module> - Remove installed module
|
|
9
|
+
* cog versions <url> - List available versions
|
|
10
|
+
* cog list - List available modules
|
|
11
|
+
* cog pipe --module <name> - Pipe mode (stdin/stdout)
|
|
12
|
+
* cog doctor - Check configuration
|
|
13
|
+
*
|
|
14
|
+
* npx cognitive-modules add ziel-io/cognitive-modules -m code-simplifier
|
|
15
|
+
*/
|
|
16
|
+
import { parseArgs } from 'node:util';
|
|
17
|
+
import { getProvider, listProviders } from './providers/index.js';
|
|
18
|
+
import { run, list, pipe, init, add, update, remove, versions } from './commands/index.js';
|
|
19
|
+
const VERSION = '0.6.0';
|
|
20
|
+
async function main() {
|
|
21
|
+
const args = process.argv.slice(2);
|
|
22
|
+
const command = args[0];
|
|
23
|
+
if (!command || command === '--help' || command === '-h') {
|
|
24
|
+
printHelp();
|
|
25
|
+
process.exit(0);
|
|
26
|
+
}
|
|
27
|
+
if (command === '--version' || command === '-v') {
|
|
28
|
+
console.log(`Cognitive Runtime v${VERSION}`);
|
|
29
|
+
process.exit(0);
|
|
30
|
+
}
|
|
31
|
+
// Parse common options
|
|
32
|
+
const { values } = parseArgs({
|
|
33
|
+
args: args.slice(1),
|
|
34
|
+
options: {
|
|
35
|
+
args: { type: 'string', short: 'a' },
|
|
36
|
+
input: { type: 'string', short: 'i' },
|
|
37
|
+
module: { type: 'string', short: 'm' },
|
|
38
|
+
model: { type: 'string', short: 'M' },
|
|
39
|
+
provider: { type: 'string', short: 'p' },
|
|
40
|
+
pretty: { type: 'boolean', default: false },
|
|
41
|
+
verbose: { type: 'boolean', short: 'V', default: false },
|
|
42
|
+
'no-validate': { type: 'boolean', default: false },
|
|
43
|
+
// Add/update options
|
|
44
|
+
name: { type: 'string', short: 'n' },
|
|
45
|
+
tag: { type: 'string', short: 't' },
|
|
46
|
+
branch: { type: 'string', short: 'b' },
|
|
47
|
+
limit: { type: 'string', short: 'l' },
|
|
48
|
+
},
|
|
49
|
+
allowPositionals: true,
|
|
50
|
+
});
|
|
51
|
+
// Get provider
|
|
52
|
+
let provider;
|
|
53
|
+
try {
|
|
54
|
+
provider = getProvider(values.provider, values.model);
|
|
55
|
+
}
|
|
56
|
+
catch (e) {
|
|
57
|
+
console.error(`Error: ${e instanceof Error ? e.message : e}`);
|
|
58
|
+
process.exit(1);
|
|
59
|
+
}
|
|
60
|
+
const ctx = {
|
|
61
|
+
cwd: process.cwd(),
|
|
62
|
+
provider,
|
|
63
|
+
verbose: values.verbose,
|
|
64
|
+
};
|
|
65
|
+
try {
|
|
66
|
+
switch (command) {
|
|
67
|
+
case 'run': {
|
|
68
|
+
const moduleName = args[1];
|
|
69
|
+
if (!moduleName || moduleName.startsWith('-')) {
|
|
70
|
+
console.error('Usage: cog run <module> [--args "..."]');
|
|
71
|
+
process.exit(1);
|
|
72
|
+
}
|
|
73
|
+
const result = await run(moduleName, ctx, {
|
|
74
|
+
args: values.args,
|
|
75
|
+
input: values.input,
|
|
76
|
+
noValidate: values['no-validate'],
|
|
77
|
+
pretty: values.pretty,
|
|
78
|
+
verbose: values.verbose,
|
|
79
|
+
});
|
|
80
|
+
if (!result.success) {
|
|
81
|
+
console.error(`Error: ${result.error}`);
|
|
82
|
+
process.exit(1);
|
|
83
|
+
}
|
|
84
|
+
console.log(JSON.stringify(result.data, null, values.pretty ? 2 : 0));
|
|
85
|
+
break;
|
|
86
|
+
}
|
|
87
|
+
case 'list': {
|
|
88
|
+
const result = await list(ctx);
|
|
89
|
+
if (!result.success) {
|
|
90
|
+
console.error(`Error: ${result.error}`);
|
|
91
|
+
process.exit(1);
|
|
92
|
+
}
|
|
93
|
+
const data = result.data;
|
|
94
|
+
if (data.modules.length === 0) {
|
|
95
|
+
console.log('No modules found.');
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
console.log('Available Modules:');
|
|
99
|
+
console.log('');
|
|
100
|
+
for (const m of data.modules) {
|
|
101
|
+
console.log(` ${m.name} (v${m.version})`);
|
|
102
|
+
console.log(` ${m.responsibility}`);
|
|
103
|
+
console.log(` ${m.location}`);
|
|
104
|
+
console.log('');
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
break;
|
|
108
|
+
}
|
|
109
|
+
case 'pipe': {
|
|
110
|
+
const moduleName = values.module || args[1];
|
|
111
|
+
if (!moduleName) {
|
|
112
|
+
console.error('Usage: cog pipe --module <name>');
|
|
113
|
+
process.exit(1);
|
|
114
|
+
}
|
|
115
|
+
await pipe(ctx, {
|
|
116
|
+
module: moduleName,
|
|
117
|
+
noValidate: values['no-validate'],
|
|
118
|
+
});
|
|
119
|
+
break;
|
|
120
|
+
}
|
|
121
|
+
case 'init': {
|
|
122
|
+
const moduleName = args[1];
|
|
123
|
+
const result = await init(ctx, moduleName);
|
|
124
|
+
if (!result.success) {
|
|
125
|
+
console.error(`Error: ${result.error}`);
|
|
126
|
+
process.exit(1);
|
|
127
|
+
}
|
|
128
|
+
const data = result.data;
|
|
129
|
+
console.log(data.message);
|
|
130
|
+
console.log(` Location: ${data.location}`);
|
|
131
|
+
if (data.files) {
|
|
132
|
+
console.log(` Files: ${data.files.join(', ')}`);
|
|
133
|
+
}
|
|
134
|
+
if (data.hint) {
|
|
135
|
+
console.log(` ${data.hint}`);
|
|
136
|
+
}
|
|
137
|
+
break;
|
|
138
|
+
}
|
|
139
|
+
case 'doctor': {
|
|
140
|
+
console.log('Cognitive Runtime - Environment Check\n');
|
|
141
|
+
console.log('Providers:');
|
|
142
|
+
for (const p of listProviders()) {
|
|
143
|
+
const status = p.configured ? '✓ configured' : '– not configured';
|
|
144
|
+
console.log(` ${p.name}: ${status} (${p.model})`);
|
|
145
|
+
}
|
|
146
|
+
console.log('');
|
|
147
|
+
try {
|
|
148
|
+
const provider = getProvider();
|
|
149
|
+
console.log(`Active provider: ${provider.name}`);
|
|
150
|
+
}
|
|
151
|
+
catch {
|
|
152
|
+
console.log('Active provider: none (set an API key)');
|
|
153
|
+
}
|
|
154
|
+
break;
|
|
155
|
+
}
|
|
156
|
+
case 'add': {
|
|
157
|
+
const url = args[1];
|
|
158
|
+
if (!url || url.startsWith('-')) {
|
|
159
|
+
console.error('Usage: cog add <url> [--module <name>] [--tag <version>]');
|
|
160
|
+
console.error('');
|
|
161
|
+
console.error('Examples:');
|
|
162
|
+
console.error(' cog add ziel-io/cognitive-modules -m code-simplifier');
|
|
163
|
+
console.error(' cog add org/repo --module my-module --tag v1.0.0');
|
|
164
|
+
process.exit(1);
|
|
165
|
+
}
|
|
166
|
+
console.log(`→ Adding module from: ${url}`);
|
|
167
|
+
if (values.module)
|
|
168
|
+
console.log(` Module path: ${values.module}`);
|
|
169
|
+
if (values.tag)
|
|
170
|
+
console.log(` Version: ${values.tag}`);
|
|
171
|
+
const result = await add(url, ctx, {
|
|
172
|
+
module: values.module,
|
|
173
|
+
name: values.name,
|
|
174
|
+
tag: values.tag,
|
|
175
|
+
branch: values.branch,
|
|
176
|
+
});
|
|
177
|
+
if (!result.success) {
|
|
178
|
+
console.error(`✗ Failed to add module: ${result.error}`);
|
|
179
|
+
process.exit(1);
|
|
180
|
+
}
|
|
181
|
+
const data = result.data;
|
|
182
|
+
console.log(`✓ ${data.message}`);
|
|
183
|
+
console.log(` Location: ${data.location}`);
|
|
184
|
+
console.log('');
|
|
185
|
+
console.log('Run with:');
|
|
186
|
+
console.log(` cog run ${data.name} --args "your input"`);
|
|
187
|
+
break;
|
|
188
|
+
}
|
|
189
|
+
case 'update': {
|
|
190
|
+
const moduleName = args[1];
|
|
191
|
+
if (!moduleName || moduleName.startsWith('-')) {
|
|
192
|
+
console.error('Usage: cog update <module> [--tag <version>]');
|
|
193
|
+
process.exit(1);
|
|
194
|
+
}
|
|
195
|
+
console.log(`→ Updating module: ${moduleName}`);
|
|
196
|
+
const result = await update(moduleName, ctx, {
|
|
197
|
+
tag: values.tag,
|
|
198
|
+
});
|
|
199
|
+
if (!result.success) {
|
|
200
|
+
console.error(`✗ ${result.error}`);
|
|
201
|
+
process.exit(1);
|
|
202
|
+
}
|
|
203
|
+
const data = result.data;
|
|
204
|
+
console.log(`✓ ${data.message}`);
|
|
205
|
+
break;
|
|
206
|
+
}
|
|
207
|
+
case 'remove': {
|
|
208
|
+
const moduleName = args[1];
|
|
209
|
+
if (!moduleName || moduleName.startsWith('-')) {
|
|
210
|
+
console.error('Usage: cog remove <module>');
|
|
211
|
+
process.exit(1);
|
|
212
|
+
}
|
|
213
|
+
const result = await remove(moduleName, ctx);
|
|
214
|
+
if (!result.success) {
|
|
215
|
+
console.error(`✗ ${result.error}`);
|
|
216
|
+
process.exit(1);
|
|
217
|
+
}
|
|
218
|
+
const data = result.data;
|
|
219
|
+
console.log(`✓ ${data.message}`);
|
|
220
|
+
break;
|
|
221
|
+
}
|
|
222
|
+
case 'versions': {
|
|
223
|
+
const url = args[1];
|
|
224
|
+
if (!url || url.startsWith('-')) {
|
|
225
|
+
console.error('Usage: cog versions <url>');
|
|
226
|
+
console.error('');
|
|
227
|
+
console.error('Examples:');
|
|
228
|
+
console.error(' cog versions ziel-io/cognitive-modules');
|
|
229
|
+
process.exit(1);
|
|
230
|
+
}
|
|
231
|
+
console.log(`→ Fetching versions from: ${url}\n`);
|
|
232
|
+
const limit = values.limit ? parseInt(values.limit, 10) : 10;
|
|
233
|
+
const result = await versions(url, ctx, { limit });
|
|
234
|
+
if (!result.success) {
|
|
235
|
+
console.error(`✗ ${result.error}`);
|
|
236
|
+
process.exit(1);
|
|
237
|
+
}
|
|
238
|
+
const data = result.data;
|
|
239
|
+
if (data.tags.length === 0) {
|
|
240
|
+
console.log('No tags/versions found.');
|
|
241
|
+
}
|
|
242
|
+
else {
|
|
243
|
+
console.log(`Available Versions (${data.count}):`);
|
|
244
|
+
console.log('');
|
|
245
|
+
for (const tag of data.tags) {
|
|
246
|
+
console.log(` ${tag}`);
|
|
247
|
+
console.log(` cog add ${url} --tag ${tag}`);
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
break;
|
|
251
|
+
}
|
|
252
|
+
default:
|
|
253
|
+
console.error(`Unknown command: ${command}`);
|
|
254
|
+
console.error('Run "cog --help" for usage.');
|
|
255
|
+
process.exit(1);
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
catch (e) {
|
|
259
|
+
console.error(`Error: ${e instanceof Error ? e.message : e}`);
|
|
260
|
+
if (values.verbose && e instanceof Error) {
|
|
261
|
+
console.error(e.stack);
|
|
262
|
+
}
|
|
263
|
+
process.exit(1);
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
function printHelp() {
|
|
267
|
+
console.log(`
|
|
268
|
+
Cognitive Runtime v${VERSION}
|
|
269
|
+
Structured AI Task Execution
|
|
270
|
+
|
|
271
|
+
USAGE:
|
|
272
|
+
cog <command> [options]
|
|
273
|
+
|
|
274
|
+
COMMANDS:
|
|
275
|
+
run <module> Run a Cognitive Module
|
|
276
|
+
list List available modules
|
|
277
|
+
add <url> Add module from GitHub
|
|
278
|
+
update <module> Update module to latest version
|
|
279
|
+
remove <module> Remove installed module
|
|
280
|
+
versions <url> List available versions
|
|
281
|
+
pipe Pipe mode (stdin/stdout)
|
|
282
|
+
init [name] Initialize project or create module
|
|
283
|
+
doctor Check configuration
|
|
284
|
+
|
|
285
|
+
OPTIONS:
|
|
286
|
+
-a, --args <str> Arguments to pass to module
|
|
287
|
+
-i, --input <json> JSON input for module
|
|
288
|
+
-m, --module <name> Module path within repo (for add)
|
|
289
|
+
-n, --name <name> Override module name (for add)
|
|
290
|
+
-t, --tag <version> Git tag/version (for add/update)
|
|
291
|
+
-b, --branch <name> Git branch (for add)
|
|
292
|
+
-M, --model <name> LLM model (e.g., gpt-4o, gemini-2.0-flash)
|
|
293
|
+
-p, --provider <name> LLM provider (gemini, openai, anthropic, deepseek, minimax, moonshot, qwen, ollama)
|
|
294
|
+
--pretty Pretty-print JSON output
|
|
295
|
+
-V, --verbose Verbose output
|
|
296
|
+
--no-validate Skip schema validation
|
|
297
|
+
-v, --version Show version
|
|
298
|
+
-h, --help Show this help
|
|
299
|
+
|
|
300
|
+
EXAMPLES:
|
|
301
|
+
# Add modules from GitHub
|
|
302
|
+
cog add ziel-io/cognitive-modules -m code-simplifier
|
|
303
|
+
cog add org/repo --module my-module --tag v1.0.0
|
|
304
|
+
|
|
305
|
+
# Version management
|
|
306
|
+
cog update code-simplifier
|
|
307
|
+
cog versions ziel-io/cognitive-modules
|
|
308
|
+
cog remove code-simplifier
|
|
309
|
+
|
|
310
|
+
# Run modules
|
|
311
|
+
cog run code-reviewer --args "def foo(): pass"
|
|
312
|
+
cog run code-reviewer --provider openai --model gpt-4o --args "..."
|
|
313
|
+
cog list
|
|
314
|
+
|
|
315
|
+
# Other
|
|
316
|
+
echo "review this code" | cog pipe --module code-reviewer
|
|
317
|
+
cog init my-module
|
|
318
|
+
cog doctor
|
|
319
|
+
|
|
320
|
+
ENVIRONMENT:
|
|
321
|
+
GEMINI_API_KEY Google Gemini
|
|
322
|
+
OPENAI_API_KEY OpenAI
|
|
323
|
+
ANTHROPIC_API_KEY Anthropic Claude
|
|
324
|
+
DEEPSEEK_API_KEY DeepSeek
|
|
325
|
+
MINIMAX_API_KEY MiniMax
|
|
326
|
+
MOONSHOT_API_KEY Moonshot (Kimi)
|
|
327
|
+
DASHSCOPE_API_KEY Alibaba Qwen (通义千问)
|
|
328
|
+
OLLAMA_HOST Ollama local (default: localhost:11434)
|
|
329
|
+
COG_MODEL Override default model for any provider
|
|
330
|
+
`);
|
|
331
|
+
}
|
|
332
|
+
main().catch(e => {
|
|
333
|
+
console.error('Fatal error:', e);
|
|
334
|
+
process.exit(1);
|
|
335
|
+
});
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Add command - Install modules from GitHub
|
|
3
|
+
*
|
|
4
|
+
* cog add ziel-io/cognitive-modules -m code-simplifier
|
|
5
|
+
* cog add https://github.com/org/repo --module name --tag v1.0.0
|
|
6
|
+
*/
|
|
7
|
+
import type { CommandContext, CommandResult } from '../types.js';
|
|
8
|
+
export interface AddOptions {
|
|
9
|
+
module?: string;
|
|
10
|
+
name?: string;
|
|
11
|
+
branch?: string;
|
|
12
|
+
tag?: string;
|
|
13
|
+
}
|
|
14
|
+
interface InstallManifest {
|
|
15
|
+
[moduleName: string]: {
|
|
16
|
+
source: string;
|
|
17
|
+
githubUrl: string;
|
|
18
|
+
modulePath?: string;
|
|
19
|
+
tag?: string;
|
|
20
|
+
branch?: string;
|
|
21
|
+
version?: string;
|
|
22
|
+
installedAt: string;
|
|
23
|
+
installedTime: string;
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Get installation info for a module
|
|
28
|
+
*/
|
|
29
|
+
export declare function getInstallInfo(moduleName: string): Promise<InstallManifest[string] | null>;
|
|
30
|
+
/**
|
|
31
|
+
* Add a module from GitHub
|
|
32
|
+
*/
|
|
33
|
+
export declare function add(url: string, ctx: CommandContext, options?: AddOptions): Promise<CommandResult>;
|
|
34
|
+
export {};
|