wormajs 0.0.2-beta.1 → 0.0.2-beta.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/README.md
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
# worma -
|
|
1
|
+
# worma - The OpenAPI Generator for human and AI
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
<img width="200px" src="https://alova.js.org/img/logo-text-vertical.svg" />
|
|
5
|
-
</p>
|
|
3
|
+

|
|
6
4
|
|
|
7
5
|
<p align="center"><b>One OpenAPI spec. Code for developers, knowledge for AI.<br />Generate API calling functions, TypeScript types, documentation, and AI Skills in a single command.</b></p>
|
|
8
6
|
|
|
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.aiDoc = aiDoc;
|
|
7
|
+
exports.parseAgentList = parseAgentList;
|
|
7
8
|
const node_child_process_1 = require("node:child_process");
|
|
8
9
|
const node_fs_1 = __importDefault(require("node:fs"));
|
|
9
10
|
const node_module_1 = require("node:module");
|
|
@@ -67,34 +68,60 @@ function aiDoc(config) {
|
|
|
67
68
|
},
|
|
68
69
|
});
|
|
69
70
|
if (installSkillEnabled) {
|
|
70
|
-
const {
|
|
71
|
-
|
|
71
|
+
const { agents } = resolveAgents(projectPath);
|
|
72
|
+
for (const agent of agents) {
|
|
73
|
+
installSkill(aidocsDir, agent, projectPath);
|
|
74
|
+
}
|
|
72
75
|
}
|
|
73
76
|
},
|
|
74
77
|
};
|
|
75
78
|
}
|
|
76
79
|
/**
|
|
77
|
-
* Resolve the target coding
|
|
80
|
+
* Resolve the target coding agents from `.env.local` in the project root.
|
|
81
|
+
*
|
|
82
|
+
* Multiple agents can be configured as a comma-separated list, e.g.
|
|
83
|
+
* `agent=cursor, claude-code, windsurf`. Both commas and surrounding
|
|
84
|
+
* whitespace are tolerated.
|
|
78
85
|
*
|
|
79
86
|
* If the file does not exist, it will be created and `.gitignore` will be
|
|
80
87
|
* updated to ignore `*.local` files. An error is then thrown asking the user
|
|
81
|
-
* to set `agent=<coding-agent
|
|
88
|
+
* to set `agent=<coding-agent>` (optionally multiple, comma-separated).
|
|
82
89
|
*
|
|
83
|
-
* If `agent` is missing, an error is thrown with guidance.
|
|
90
|
+
* If `agent` is missing or empty, an error is thrown with guidance.
|
|
84
91
|
*/
|
|
85
|
-
function
|
|
92
|
+
function resolveAgents(projectPath) {
|
|
86
93
|
const envFilePath = node_path_1.default.join(projectPath, '.env.local');
|
|
87
94
|
if (!node_fs_1.default.existsSync(envFilePath)) {
|
|
88
95
|
createEnvLocalFile(envFilePath);
|
|
89
96
|
ensureGitIgnoreLocal(projectPath);
|
|
90
|
-
throw logger_1.logger.throwError(`${prefix}Created .env.local at project root. Please set the coding agent you are using, e.g. agent=cursor. Supported agents list: ${SKILLS_SUPPORTED_AGENTS_URL}`);
|
|
97
|
+
throw logger_1.logger.throwError(`${prefix}Created .env.local at project root. Please set the coding agent you are using, e.g. agent=cursor or multiple agents comma-separated: agent=cursor,claude-code. Supported agents list: ${SKILLS_SUPPORTED_AGENTS_URL}`);
|
|
91
98
|
}
|
|
92
99
|
const content = node_fs_1.default.readFileSync(envFilePath, 'utf-8');
|
|
93
|
-
const
|
|
94
|
-
|
|
95
|
-
|
|
100
|
+
const raw = parseEnvValue(content, 'agent') ?? '';
|
|
101
|
+
const agents = parseAgentList(raw);
|
|
102
|
+
if (agents.length === 0) {
|
|
103
|
+
throw logger_1.logger.throwError(`${prefix}Missing "agent" in .env.local at project root. Please set the coding agent you are using, e.g. agent=cursor or multiple agents comma-separated: agent=cursor,claude-code. Supported agents list: ${SKILLS_SUPPORTED_AGENTS_URL}`);
|
|
104
|
+
}
|
|
105
|
+
return { agents };
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Parse an agent string into a deduplicated list of trimmed agent names.
|
|
109
|
+
*
|
|
110
|
+
* Agents may be separated by either an English comma (`,`) or a Chinese
|
|
111
|
+
* comma (`,`), with any amount of whitespace (including none) allowed on
|
|
112
|
+
* either side. Empty entries are ignored.
|
|
113
|
+
*/
|
|
114
|
+
function parseAgentList(raw) {
|
|
115
|
+
const seen = new Set();
|
|
116
|
+
const result = [];
|
|
117
|
+
for (const part of raw.split(/[,,]/)) {
|
|
118
|
+
const agent = part.trim();
|
|
119
|
+
if (!agent || seen.has(agent))
|
|
120
|
+
continue;
|
|
121
|
+
seen.add(agent);
|
|
122
|
+
result.push(agent);
|
|
96
123
|
}
|
|
97
|
-
return
|
|
124
|
+
return result;
|
|
98
125
|
}
|
|
99
126
|
/**
|
|
100
127
|
* Resolve the absolute path to the `skills` CLI installed alongside this package.
|
|
@@ -130,7 +157,8 @@ function installSkill(skillPath, agent, projectPath) {
|
|
|
130
157
|
}
|
|
131
158
|
function createEnvLocalFile(envFilePath) {
|
|
132
159
|
const content = `# Worma aiDoc skill installer configuration
|
|
133
|
-
# Please set the coding agent you are using (e.g. cursor, claude-code, windsurf).
|
|
160
|
+
# Please set the coding agent(s) you are using (e.g. cursor, claude-code, windsurf).
|
|
161
|
+
# You can configure multiple agents comma-separated, e.g. agent=cursor,claude-code.
|
|
134
162
|
# Supported agents list: ${SKILLS_SUPPORTED_AGENTS_URL}
|
|
135
163
|
agent=
|
|
136
164
|
`;
|
package/package.json
CHANGED
package/typings/plugins.d.ts
CHANGED
|
@@ -426,6 +426,14 @@ export interface AiDocConfig {
|
|
|
426
426
|
installSkill?: boolean;
|
|
427
427
|
}
|
|
428
428
|
export declare function aiDoc(config?: AiDocConfig): ApiPlugin;
|
|
429
|
+
/**
|
|
430
|
+
* Parse an agent string into a deduplicated list of trimmed agent names.
|
|
431
|
+
*
|
|
432
|
+
* Agents may be separated by either an English comma (`,`) or a Chinese
|
|
433
|
+
* comma (`,`), with any amount of whitespace (including none) allowed on
|
|
434
|
+
* either side. Empty entries are ignored.
|
|
435
|
+
*/
|
|
436
|
+
export declare function parseAgentList(raw: string): string[];
|
|
429
437
|
export type ScopeType = "ALL" | "SELECTED_ENDPOINTS" | "SELECTED_TAGS" | "SELECTED_FOLDERS";
|
|
430
438
|
export interface APIFoxBody {
|
|
431
439
|
scope?: {
|