opencode-leetcode-realworld 0.2.1 → 0.2.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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/scaffold.ts +24 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencode-leetcode-realworld",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "OpenCode plugin that turns a LeetCode problem into a realistic software-engineering assignment, so you practice applying the underlying algorithm instead of solving the puzzle.",
5
5
  "type": "module",
6
6
  "license": "MIT",
package/src/scaffold.ts CHANGED
@@ -130,6 +130,29 @@ function edgeCaseSection(spec: ScaffoldSpec): string {
130
130
  return `## Edge cases to handle\n\n${edgeCases.map((edge) => `- ${edge}`).join("\n")}\n`;
131
131
  }
132
132
 
133
+ function exampleSection(spec: ScaffoldSpec): string {
134
+ const tests = spec.publicTests ?? [];
135
+ if (tests.length === 0) return "";
136
+ const blocks = tests.slice(0, 3).map((test, index) => {
137
+ const input = json(test.input);
138
+ const output = json(test.expected);
139
+ return `### Example ${index + 1}: ${test.name}
140
+
141
+ **Input**
142
+
143
+ \`\`\`json
144
+ ${input}
145
+ \`\`\`
146
+
147
+ **Output**
148
+
149
+ \`\`\`json
150
+ ${output}
151
+ \`\`\``;
152
+ });
153
+ return `## Example input / output\n\nUse these to derive the logic.\n\n${blocks.join("\n\n")}\n`;
154
+ }
155
+
133
156
  function readmeFor(names: ResolvedNames, spec: ScaffoldSpec, language: LanguageId): string {
134
157
  const adapter = getLanguage(language);
135
158
  const source = `src/solution.${adapter.extension}`;
@@ -176,6 +199,7 @@ function projectDoc(spec: ScaffoldSpec, names: ResolvedNames, language: Language
176
199
 
177
200
  ${spec.scenario.trim()}
178
201
 
202
+ ${exampleSection(spec)}
179
203
  ${requirementsSection(spec)}
180
204
  ${edgeCaseSection(spec)}
181
205
  ## Interface