Skip to content

Commit b2f4fb4

Browse files
tercelclaude
andcommitted
docs: make init command spec language-agnostic — each CLI generates its own language
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 4d08953 commit b2f4fb4

File tree

1 file changed

+41
-25
lines changed

1 file changed

+41
-25
lines changed

docs/features/init-command.md

Lines changed: 41 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -58,37 +58,60 @@ The `module_id` argument is split on the **last** `.` to derive `(prefix, func_n
5858

5959
### 4.3 Style: `decorator` (default dir: `extensions/`)
6060

61-
Generates a single Python file at `{dir}/{module_id_with_underscores}.py`:
61+
Generates a single source file at `{dir}/{module_id_with_underscores}.{ext}` using the host language's module definition syntax. Each CLI implementation generates code in its own language:
6262

63+
**Python** (`.py`):
6364
```python
64-
"""Module: {module_id}"""
65-
6665
from apcore import module
6766

68-
6967
@module(id="{module_id}", description="{description}")
7068
def {func_name}() -> dict:
71-
"""{description}"""
7269
# TODO: implement
7370
return {"status": "ok"}
7471
```
7572

76-
### 4.4 Style: `convention` (default dir: `commands/`)
77-
78-
Generates a Python file in a directory structure derived from the prefix. Multi-segment prefixes create nested directories.
73+
**TypeScript** (`.ts`):
74+
```typescript
75+
import { module } from "apcore-js";
76+
import { Type } from "@sinclair/typebox";
77+
78+
export const {funcName}Module = module({
79+
id: "{module_id}",
80+
description: "{description}",
81+
inputSchema: Type.Object({}),
82+
outputSchema: Type.Object({ status: Type.String() }),
83+
execute: (_inputs) => {
84+
// TODO: implement
85+
return { status: "ok" };
86+
},
87+
});
88+
```
7989

80-
```python
81-
"""{description}"""
90+
**Rust** (`.rs`):
91+
```rust
92+
use apcore::module::Module;
93+
use apcore::context::Context;
94+
use apcore::errors::ModuleError;
95+
use async_trait::async_trait;
96+
use serde_json::{json, Value};
97+
98+
pub struct {FuncName}Module;
99+
100+
#[async_trait]
101+
impl Module for {FuncName}Module {
102+
fn description(&self) -> &str { "{description}" }
103+
// ... input_schema, output_schema, execute
104+
}
105+
```
82106

83-
CLI_GROUP = "{first_prefix_segment}"
107+
### 4.4 Style: `convention` (default dir: `commands/`)
84108

85-
def {func_name}() -> dict:
86-
"""{description}"""
87-
# TODO: implement
88-
return {"status": "ok"}
89-
```
109+
Generates a source file in a directory structure derived from the prefix. Multi-segment prefixes create nested directories. Each implementation uses its own language syntax.
90110

91-
The `CLI_GROUP` line is only emitted when the `module_id` contains a `.` separator.
111+
The `CLI_GROUP` constant is only emitted when the `module_id` contains a `.` separator. Language-specific syntax:
112+
- Python: `CLI_GROUP = "{group}"`
113+
- TypeScript: `export const CLI_GROUP = "{group}";`
114+
- Rust: `pub const CLI_GROUP: &str = "{group}";`
92115

93116
### 4.5 Style: `binding` (default dir: `bindings/`)
94117

@@ -104,14 +127,7 @@ bindings:
104127
auto_schema: true
105128
```
106129
107-
2. **Companion source** at `commands/{prefix_with_underscores}.py` (only if it does not already exist):
108-
109-
```python
110-
def {func_name}() -> dict:
111-
"""{description}"""
112-
# TODO: implement
113-
return {"status": "ok"}
114-
```
130+
2. **Companion source** at `commands/{prefix_with_underscores}.{ext}` (only if it does not already exist), using the host language's function syntax.
115131

116132
### 4.6 Options
117133

0 commit comments

Comments
 (0)