kopular 1.2.6 → 1.3.1
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/GUIDE.md +6 -0
- package/bin/kp.mjs +29 -9
- package/package.json +1 -1
package/GUIDE.md
CHANGED
|
@@ -25,6 +25,12 @@ hint — so running a separate build before it only adds a round-trip (the build
|
|
|
25
25
|
well under a second). `ks check src/app.ks` type-checks without building, for when you only
|
|
26
26
|
want the errors.
|
|
27
27
|
|
|
28
|
+
**A fresh `kp new` project's `src/` is exactly three files, all shown in this guide:**
|
|
29
|
+
`app.ks` (the block above), `counter.ks` (the `Counter` class under Components, plus
|
|
30
|
+
`using "kopular";`), and `counter.html` (its template, right below it). `index.html` already
|
|
31
|
+
maps every Kopular module and never needs editing. There's nothing else to discover — read
|
|
32
|
+
the task, then write your files.
|
|
33
|
+
|
|
28
34
|
## The language you need
|
|
29
35
|
|
|
30
36
|
- `Type name = value;` for every local — no `let`/`var`, no inference on declarations.
|
package/bin/kp.mjs
CHANGED
|
@@ -180,15 +180,8 @@ const COUNTER_KS_TEMPLATE = `using "kopular";
|
|
|
180
180
|
|
|
181
181
|
class Counter : Component {
|
|
182
182
|
public state<number> Count;
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
this.Count = state(0);
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
public void Increment() {
|
|
189
|
-
this.Count.Value = this.Count.Value + 1;
|
|
190
|
-
}
|
|
191
|
-
|
|
183
|
+
constructor() : base() { this.Count = state(0); }
|
|
184
|
+
public void Increment() { this.Count.Value = this.Count.Value + 1; }
|
|
192
185
|
template from "./counter.html";
|
|
193
186
|
}
|
|
194
187
|
`;
|
|
@@ -203,6 +196,31 @@ Counter app = new Counter();
|
|
|
203
196
|
app.Mount(document.body);
|
|
204
197
|
`;
|
|
205
198
|
|
|
199
|
+
// Loaded automatically at session start by AI coding agents (AGENTS.md is the
|
|
200
|
+
// cross-tool convention; Claude Code reads CLAUDE.md, which imports it). Kept
|
|
201
|
+
// deliberately tiny, because it sits in every request's context. Its one job is
|
|
202
|
+
// routing: an agent that opens node_modules/kopular/LLM.md (~53K chars) before
|
|
203
|
+
// GUIDE.md (~15K) pays for that on every call after, and benchmark transcripts
|
|
204
|
+
// showed agents never read a project's README unprompted.
|
|
205
|
+
const AGENTS_MD_TEMPLATE = `# Notes for AI coding agents
|
|
206
|
+
|
|
207
|
+
This app is KopScript + Kopular: a typed language that compiles to JavaScript, and is
|
|
208
|
+
probably not in your training data.
|
|
209
|
+
|
|
210
|
+
- **Read \`node_modules/kopular/GUIDE.md\` first**, in full: one page covering the language
|
|
211
|
+
subset, components, templates, forms, HTTP and routing. Search the much longer
|
|
212
|
+
\`node_modules/kopular/LLM.md\` and \`node_modules/kopscript/LLM.md\` only for what it
|
|
213
|
+
doesn't cover.
|
|
214
|
+
- **Check your work with one command.** \`npm run build\` compiles \`src/app.ks\` and every file
|
|
215
|
+
it \`using\`s in well under a second and prints every error with a \`fix:\` hint. Anything
|
|
216
|
+
that runs the app or its tests builds first, so don't run a separate build before it.
|
|
217
|
+
- Kopular's source in \`node_modules\` isn't its documentation — try GUIDE.md, the compiler's
|
|
218
|
+
hint, then the LLM.md references before reading it.
|
|
219
|
+
`;
|
|
220
|
+
|
|
221
|
+
const CLAUDE_MD_TEMPLATE = `@AGENTS.md
|
|
222
|
+
`;
|
|
223
|
+
|
|
206
224
|
function scaffoldProject(dirPath) {
|
|
207
225
|
const name = basename(dirPath);
|
|
208
226
|
if (existsSync(dirPath) && readdirSync(dirPath).length > 0) {
|
|
@@ -218,6 +236,8 @@ function scaffoldProject(dirPath) {
|
|
|
218
236
|
writeFileSync(join(dirPath, "index.html"), indexHtmlTemplate(), "utf-8");
|
|
219
237
|
writeFileSync(join(dirPath, ".gitignore"), GITIGNORE_TEMPLATE, "utf-8");
|
|
220
238
|
writeFileSync(join(dirPath, "README.md"), readmeTemplate(name), "utf-8");
|
|
239
|
+
writeFileSync(join(dirPath, "AGENTS.md"), AGENTS_MD_TEMPLATE, "utf-8");
|
|
240
|
+
writeFileSync(join(dirPath, "CLAUDE.md"), CLAUDE_MD_TEMPLATE, "utf-8");
|
|
221
241
|
writeFileSync(join(dirPath, "scripts", "serve.mjs"), SERVE_MJS_TEMPLATE, "utf-8");
|
|
222
242
|
writeFileSync(join(dirPath, "scripts", "vendor-kopular.mjs"), VENDOR_KOPULAR_MJS_TEMPLATE, "utf-8");
|
|
223
243
|
writeFileSync(join(dirPath, "src", "counter.ks"), COUNTER_KS_TEMPLATE, "utf-8");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "kopular",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.1",
|
|
4
4
|
"description": "Kopular: a small component framework for KopScript — components, reactive state, constructor-injected services, routing, real compiled templates, and HTTP, with no DI container",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|