@ahmed-3m/idea2prototype 0.9.0 → 0.9.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/CHANGELOG.md +5 -0
- package/README.md +12 -10
- package/agents/AGENTS.md +11 -9
- package/agents/CLAUDE.md +11 -9
- package/package.json +1 -1
- package/skills/idea2prototype/scripts/idea2prototype.mjs +17 -2
- package/skills/idea2prototype/templates/api/.idea2prototype.json +1 -1
- package/skills/idea2prototype/templates/api/package.json +1 -1
- package/skills/idea2prototype/templates/cli/.idea2prototype.json +1 -1
- package/skills/idea2prototype/templates/cli/package.json +1 -1
- package/skills/idea2prototype/templates/library/.idea2prototype.json +1 -1
- package/skills/idea2prototype/templates/library/package.json +1 -1
- package/skills/idea2prototype/templates/web/.idea2prototype.json +1 -1
- package/skills/idea2prototype/templates/web/package.json +1 -1
- package/skills/idea2prototype/templates/worker/.idea2prototype.json +1 -1
- package/skills/idea2prototype/templates/worker/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.9.1
|
|
4
|
+
|
|
5
|
+
- Fix: scaffolds made through a published install (`npx`, `npm i -g`) now pin registry coordinates in the check script (`npx -y @ahmed-3m/idea2prototype@<scaffold-version> check`) instead of an absolute path into the volatile npx cache — `npm run check` survives `npm cache clean` and runs on a second machine. Checkouts (repo clone, plugin cache) still pin the stable local engine path; the exact-version guarantee is unchanged either way. Template placeholder renamed `__IDEA2PROTOTYPE_BIN__` → `__IDEA2PROTOTYPE_CMD__` to match the broader contract.
|
|
6
|
+
- CI: release publishes now fail loudly when `NPM_TOKEN` is missing instead of skipping with a warning — npmjs is the documented primary channel, and a mirror-only release with a green run would silently invert the README's install claims. Manual `workflow_dispatch` without the secret keeps the visible skip.
|
|
7
|
+
|
|
3
8
|
## 0.9.0
|
|
4
9
|
|
|
5
10
|
- Feature: `add worker-jobs` — the worker template's persistent job queue as a feature module for web/api projects: `enqueue`/`list`/`registerHandler`, `data/jobs.json` persistence, 3 attempts with a terminal `failed` state, disposable demo routes `POST/GET /api/jobs`. `enqueue` auto-kicks a background drain; concurrent enqueues share one serialized drain, so double-processing is designed out, and the drain exits on an empty queue (no long-lived timer; server `close()` unaffected). Closes the previously documented "web app + background jobs" cross-template gap. Review-hardened: memoized cold load (concurrent first enqueues share one array), chained atomic store writes (write-to-tmp + rename; a failed write can't poison later ones or leave a half-written store), honest drain diagnostics, handler contract documented.
|
package/README.md
CHANGED
|
@@ -15,7 +15,7 @@ Idea2Prototype check — PASS (3/3)
|
|
|
15
15
|
boot PASS GET /api/health -> 200, GET / -> 200 in 45ms
|
|
16
16
|
```
|
|
17
17
|
|
|
18
|
-
**Status:** v0.
|
|
18
|
+
**Status:** v0.9.0 · actively maintained · 0.x — the check/verify contract and template shapes are stable; new capabilities arrive as `add` modules.
|
|
19
19
|
|
|
20
20
|
That verdict is the whole idea: an agent building a prototype should **never generate boilerplate it didn't need to, and never read logs it didn't need to**. The syntax step covers server code (`node --check`) and every `.js` under `public/`, recursively (parsed as both ESM and classic script — only code broken in both modes fails).
|
|
21
21
|
|
|
@@ -56,25 +56,27 @@ Templates: `web` (static frontend + health + auto-loading routes), `api` (JSON A
|
|
|
56
56
|
|
|
57
57
|
## Quickstart
|
|
58
58
|
|
|
59
|
-
**Any agent or plain shell —
|
|
59
|
+
**Any agent or plain shell — npx straight off npmjs, no clone needed:**
|
|
60
60
|
|
|
61
61
|
```bash
|
|
62
|
-
|
|
63
|
-
node idea2prototype/skills/idea2prototype/scripts/idea2prototype.mjs new my-app --template web --name "My App" --idea "recipe box"
|
|
62
|
+
npx @ahmed-3m/idea2prototype new my-app --template web --name "My App" --idea "recipe box"
|
|
64
63
|
cd my-app && npm start # http://127.0.0.1:3000
|
|
65
64
|
npm run check # the verdict above
|
|
66
|
-
|
|
65
|
+
npx @ahmed-3m/idea2prototype add api-crud --resource recipes
|
|
67
66
|
npm run check # still PASS — now with CRUD tests
|
|
68
67
|
```
|
|
69
68
|
|
|
70
|
-
**
|
|
69
|
+
**From a clean clone** (offline / air-gapped, or pinning the engine alongside the project):
|
|
71
70
|
|
|
72
71
|
```bash
|
|
73
|
-
|
|
74
|
-
|
|
72
|
+
git clone https://github.com/ahmed-3m/idea2prototype
|
|
73
|
+
node idea2prototype/skills/idea2prototype/scripts/idea2prototype.mjs new my-app --template web --name "My App" --idea "recipe box"
|
|
74
|
+
cd my-app && npm start # http://127.0.0.1:3000
|
|
75
|
+
node ../idea2prototype/skills/idea2prototype/scripts/idea2prototype.mjs add api-crud --resource recipes
|
|
76
|
+
npm run check # still PASS — now with CRUD tests
|
|
75
77
|
```
|
|
76
78
|
|
|
77
|
-
|
|
79
|
+
Every release publishes `@ahmed-3m/idea2prototype` to npmjs.org — the primary channel — and mirrors it on the GitHub Packages registry under the same name; that registry asks consumers for a token in `.npmrc` even for public packages, so treat it as the mirror. (`npm i -g @ahmed-3m/idea2prototype` gets you the short `i2p` command the table above uses.)
|
|
78
80
|
|
|
79
81
|
**ZCode plugin:** add this repo's marketplace, install `idea2prototype`, then pick the skill in the composer or use `/proto-new a recipe box with search`.
|
|
80
82
|
|
|
@@ -119,7 +121,7 @@ The generated CRUD test then needs a session instead of anonymous POSTs — regi
|
|
|
119
121
|
4. **No destructive operations.** `new` refuses non-empty directories.
|
|
120
122
|
5. **Portable core.** One `.mjs` engine; plugin/skill/npm wrappers are sugar.
|
|
121
123
|
|
|
122
|
-
One deliberate tradeoff: a scaffolded project's `npm run check` invokes the exact engine that scaffolded it, so older prototypes keep the behavior they were built with (run a newer engine by hand and it reports the drift note). An
|
|
124
|
+
One deliberate tradeoff: a scaffolded project's `npm run check` invokes the exact engine version that scaffolded it — a clone-scaffolded project pins the sibling engine path, an npx-scaffolded project pins registry coordinates (`npx -y @ahmed-3m/idea2prototype@<version> check`), so a cleared npx cache or a second machine just re-fetches the same version — and older prototypes keep the behavior they were built with (run a newer engine by hand and it reports the drift note). An always-current check remains on the roadmap.
|
|
123
125
|
|
|
124
126
|
Another boundary worth naming: templates are single-purpose and do not compose with each other — features compose within a template (auth × CRUD, rate-limit, cors, sse, worker-jobs). The one gap this used to leave — a web/api app that also needs background jobs — is closed by `add worker-jobs`, which brings the worker template's persistent queue in as a feature module; anything bigger than that still scaffolds as the primary template with the smaller part hand-built.
|
|
125
127
|
|
package/agents/AGENTS.md
CHANGED
|
@@ -2,23 +2,25 @@
|
|
|
2
2
|
|
|
3
3
|
Copy this file into any project where your coding agent should build with idea2prototype. Works with any agent that reads AGENTS.md conventions.
|
|
4
4
|
|
|
5
|
-
You have `idea2prototype` (`i2p`) available — a zero-dependency prototype tool. Use it instead of hand-writing scaffolding. If the npm package isn't installed or available, run the engine directly instead of `npx idea2prototype`: `node <path-to-idea2prototype-repo>/skills/idea2prototype/scripts/idea2prototype.mjs <command>`.
|
|
5
|
+
You have `idea2prototype` (`i2p`) available — a zero-dependency prototype tool. Use it instead of hand-writing scaffolding. If the npm package isn't installed or available, run the engine directly instead of `npx @ahmed-3m/idea2prototype`: `node <path-to-idea2prototype-repo>/skills/idea2prototype/scripts/idea2prototype.mjs <command>`.
|
|
6
6
|
|
|
7
7
|
## Commands
|
|
8
8
|
|
|
9
|
-
- `npx idea2prototype new <dir> --template web|api|cli|worker|library` — scaffold a running, tested project (~0 tokens vs 10–30k hand-written)
|
|
10
|
-
- `npx idea2prototype add api-crud --resource <name>` — JSON-file CRUD resource + roundtrip tests
|
|
11
|
-
- `npx idea2prototype add auth-local` — register/login/logout/me (scrypt + signed cookies) + tests; `requireAuth` protects other routes
|
|
12
|
-
- `npx idea2prototype add upload` — multipart file uploads + fetch-back + tests
|
|
13
|
-
- `npx idea2prototype add rate-limit` — per-key fixed-window limiter (429 + Retry-After headers); `rateLimit()` wraps any handler
|
|
14
|
-
- `npx idea2prototype add cors` — CORS wrapper (preflight + access-control-* headers, origin allowlists); `cors()` wraps any handler
|
|
9
|
+
- `npx @ahmed-3m/idea2prototype new <dir> --template web|api|cli|worker|library` — scaffold a running, tested project (~0 tokens vs 10–30k hand-written)
|
|
10
|
+
- `npx @ahmed-3m/idea2prototype add api-crud --resource <name>` — JSON-file CRUD resource + roundtrip tests
|
|
11
|
+
- `npx @ahmed-3m/idea2prototype add auth-local` — register/login/logout/me (scrypt + signed cookies) + tests; `requireAuth` protects other routes
|
|
12
|
+
- `npx @ahmed-3m/idea2prototype add upload` — multipart file uploads + fetch-back + tests
|
|
13
|
+
- `npx @ahmed-3m/idea2prototype add rate-limit` — per-key fixed-window limiter (429 + Retry-After headers); `rateLimit()` wraps any handler
|
|
14
|
+
- `npx @ahmed-3m/idea2prototype add cors` — CORS wrapper (preflight + access-control-* headers, origin allowlists); `cors()` wraps any handler
|
|
15
|
+
- `npx @ahmed-3m/idea2prototype add sse` — Server-Sent Events stream (`GET /api/events`) + heartbeats
|
|
16
|
+
- `npx @ahmed-3m/idea2prototype add worker-jobs` — persistent background job queue (`data/jobs.json`, 3 attempts) with demo routes
|
|
15
17
|
- `npm run check` (inside a project) — syntax + tests + boot, ~10-line verdict
|
|
16
|
-
- `npx idea2prototype map` — paths + LOC + exports; read this before opening files
|
|
18
|
+
- `npx @ahmed-3m/idea2prototype map` — paths + LOC + exports; read this before opening files
|
|
17
19
|
|
|
18
20
|
## Workflow
|
|
19
21
|
|
|
20
22
|
1. Scaffold with `new`, then fill `PROTOTYPE.md` (Goal ≤ 3 bullets, 1–3 core flows, out-of-scope).
|
|
21
23
|
2. Never hand-write files the tool owns (`server.mjs`, scaffold `tests/`, `package.json`). Add capabilities with `add`, not from scratch.
|
|
22
24
|
3. After every meaningful change: `npm run check`. Read the verdict only — never run tests directly, never read raw logs.
|
|
23
|
-
4. Need context? `
|
|
25
|
+
4. Need context? `npx @ahmed-3m/idea2prototype map` first; open only the files you're changing.
|
|
24
26
|
5. Done = check PASS + spec flows work. Report the verdict lines.
|
package/agents/CLAUDE.md
CHANGED
|
@@ -2,23 +2,25 @@
|
|
|
2
2
|
|
|
3
3
|
Copy this file into any project where your coding agent should build with idea2prototype. Works with any agent that reads AGENTS.md/CLAUDE.md conventions.
|
|
4
4
|
|
|
5
|
-
You have `idea2prototype` (`i2p`) available — a zero-dependency prototype tool. Use it instead of hand-writing scaffolding. If the npm package isn't installed or available, run the engine directly instead of `npx idea2prototype`: `node <path-to-idea2prototype-repo>/skills/idea2prototype/scripts/idea2prototype.mjs <command>`.
|
|
5
|
+
You have `idea2prototype` (`i2p`) available — a zero-dependency prototype tool. Use it instead of hand-writing scaffolding. If the npm package isn't installed or available, run the engine directly instead of `npx @ahmed-3m/idea2prototype`: `node <path-to-idea2prototype-repo>/skills/idea2prototype/scripts/idea2prototype.mjs <command>`.
|
|
6
6
|
|
|
7
7
|
## Commands
|
|
8
8
|
|
|
9
|
-
- `npx idea2prototype new <dir> --template web|api|cli|worker|library` — scaffold a running, tested project (~0 tokens vs 10–30k hand-written)
|
|
10
|
-
- `npx idea2prototype add api-crud --resource <name>` — JSON-file CRUD resource + roundtrip tests
|
|
11
|
-
- `npx idea2prototype add auth-local` — register/login/logout/me (scrypt + signed cookies) + tests; `requireAuth` protects other routes
|
|
12
|
-
- `npx idea2prototype add upload` — multipart file uploads + fetch-back + tests
|
|
13
|
-
- `npx idea2prototype add rate-limit` — per-key fixed-window limiter (429 + Retry-After headers); `rateLimit()` wraps any handler
|
|
14
|
-
- `npx idea2prototype add cors` — CORS wrapper (preflight + access-control-* headers, origin allowlists); `cors()` wraps any handler
|
|
9
|
+
- `npx @ahmed-3m/idea2prototype new <dir> --template web|api|cli|worker|library` — scaffold a running, tested project (~0 tokens vs 10–30k hand-written)
|
|
10
|
+
- `npx @ahmed-3m/idea2prototype add api-crud --resource <name>` — JSON-file CRUD resource + roundtrip tests
|
|
11
|
+
- `npx @ahmed-3m/idea2prototype add auth-local` — register/login/logout/me (scrypt + signed cookies) + tests; `requireAuth` protects other routes
|
|
12
|
+
- `npx @ahmed-3m/idea2prototype add upload` — multipart file uploads + fetch-back + tests
|
|
13
|
+
- `npx @ahmed-3m/idea2prototype add rate-limit` — per-key fixed-window limiter (429 + Retry-After headers); `rateLimit()` wraps any handler
|
|
14
|
+
- `npx @ahmed-3m/idea2prototype add cors` — CORS wrapper (preflight + access-control-* headers, origin allowlists); `cors()` wraps any handler
|
|
15
|
+
- `npx @ahmed-3m/idea2prototype add sse` — Server-Sent Events stream (`GET /api/events`) + heartbeats
|
|
16
|
+
- `npx @ahmed-3m/idea2prototype add worker-jobs` — persistent background job queue (`data/jobs.json`, 3 attempts) with demo routes
|
|
15
17
|
- `npm run check` (inside a project) — syntax + tests + boot, ~10-line verdict
|
|
16
|
-
- `npx idea2prototype map` — paths + LOC + exports; read this before opening files
|
|
18
|
+
- `npx @ahmed-3m/idea2prototype map` — paths + LOC + exports; read this before opening files
|
|
17
19
|
|
|
18
20
|
## Workflow
|
|
19
21
|
|
|
20
22
|
1. Scaffold with `new`, then fill `PROTOTYPE.md` (Goal ≤ 3 bullets, 1–3 core flows, out-of-scope).
|
|
21
23
|
2. Never hand-write files the tool owns (`server.mjs`, scaffold `tests/`, `package.json`). Add capabilities with `add`, not from scratch.
|
|
22
24
|
3. After every meaningful change: `npm run check`. Read the verdict only — never run tests directly, never read raw logs.
|
|
23
|
-
4. Need context? `
|
|
25
|
+
4. Need context? `npx @ahmed-3m/idea2prototype map` first; open only the files you're changing.
|
|
24
26
|
5. Done = check PASS + spec flows work. Report the verdict lines.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ahmed-3m/idea2prototype",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.1",
|
|
4
4
|
"description": "Turn ideas into tested prototypes — token-lean scaffolds + one-command verification for any coding agent. Zero dependencies.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -18,7 +18,8 @@ import { spawnSync } from 'node:child_process';
|
|
|
18
18
|
import { basename, dirname, extname, join, relative, resolve, sep } from 'node:path';
|
|
19
19
|
import { fileURLToPath, pathToFileURL } from 'node:url';
|
|
20
20
|
|
|
21
|
-
const VERSION = '0.9.
|
|
21
|
+
const VERSION = '0.9.1';
|
|
22
|
+
const PKG_NAME = '@ahmed-3m/idea2prototype';
|
|
22
23
|
const HERE = dirname(fileURLToPath(import.meta.url));
|
|
23
24
|
const TEMPLATES_DIR = join(HERE, '..', 'templates');
|
|
24
25
|
const FEATURES_DIR = join(TEMPLATES_DIR, 'features');
|
|
@@ -27,6 +28,20 @@ const TEXT_EXTENSIONS = new Set(['.md', '.json', '.html', '.js', '.mjs', '.css',
|
|
|
27
28
|
const SAY = (...args) => console.log(...args);
|
|
28
29
|
const FAIL = (...args) => console.error(...args);
|
|
29
30
|
|
|
31
|
+
// The scaffold's `npm run check` must keep invoking the engine that built it.
|
|
32
|
+
// From a published install (npx cache, npm i -g) the engine lives inside a
|
|
33
|
+
// volatile node_modules dir that a cache clean or a second machine erases —
|
|
34
|
+
// pin the registry coordinates instead, which re-fetch the exact version.
|
|
35
|
+
// From a source checkout (repo clone, plugin cache) the local path is stable.
|
|
36
|
+
// The JSON.stringify wrapper keeps the command embeddable in package.json.
|
|
37
|
+
function engineCheckCommand() {
|
|
38
|
+
const enginePath = fileURLToPath(import.meta.url);
|
|
39
|
+
const command = enginePath.includes(join('node_modules', PKG_NAME))
|
|
40
|
+
? `npx -y ${PKG_NAME}@${VERSION} check`
|
|
41
|
+
: `node "${enginePath}" check`;
|
|
42
|
+
return JSON.stringify(command).slice(1, -1); // embed inside the template's JSON string value
|
|
43
|
+
}
|
|
44
|
+
|
|
30
45
|
// ---------------------------------------------------------------------------
|
|
31
46
|
// new
|
|
32
47
|
// ---------------------------------------------------------------------------
|
|
@@ -58,7 +73,7 @@ async function cmdNew(rest) {
|
|
|
58
73
|
'{{name}}': name,
|
|
59
74
|
'{{slug}}': slug,
|
|
60
75
|
'{{idea}}': idea,
|
|
61
|
-
|
|
76
|
+
__IDEA2PROTOTYPE_CMD__: engineCheckCommand(),
|
|
62
77
|
});
|
|
63
78
|
|
|
64
79
|
const markerPath = join(target, '.idea2prototype.json');
|