@shrkcrft/templates 0.1.0-alpha.7 → 0.1.0-alpha.9
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 +1 -1
- package/dist/template-renderer.d.ts.map +1 -1
- package/dist/template-renderer.js +21 -1
- package/package.json +6 -7
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
SharkCraft templates: typed template definitions, registry, variable validation, rendering.
|
|
4
4
|
|
|
5
|
-
Part of [SharkCraft](https://github.com/
|
|
5
|
+
Part of [SharkCraft](https://github.com/sharkcraft/sharkcraft) — a deterministic, local-first toolkit that gives AI coding agents durable project context. See the main repo for documentation, examples, and the `shrk` CLI.
|
|
6
6
|
|
|
7
7
|
## Install
|
|
8
8
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"template-renderer.d.ts","sourceRoot":"","sources":["../src/template-renderer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EACf,mBAAmB,EACnB,aAAa,EACd,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAErE,MAAM,WAAW,iBAAiB;IAChC,UAAU,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,KAAK,EAAE,aAAa,EAAE,CAAC;IACvB;;;;OAIG;IACH,OAAO,EAAE,eAAe,EAAE,CAAC;IAC3B,mBAAmB,EAAE,SAAS,MAAM,EAAE,CAAC;CACxC;AAED,wBAAgB,cAAc,CAC5B,QAAQ,EAAE,mBAAmB,EAC7B,MAAM,EAAE,sBAAsB,GAC7B,iBAAiB,
|
|
1
|
+
{"version":3,"file":"template-renderer.d.ts","sourceRoot":"","sources":["../src/template-renderer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,eAAe,EACf,mBAAmB,EACnB,aAAa,EACd,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,wBAAwB,CAAC;AAErE,MAAM,WAAW,iBAAiB;IAChC,UAAU,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,KAAK,EAAE,aAAa,EAAE,CAAC;IACvB;;;;OAIG;IACH,OAAO,EAAE,eAAe,EAAE,CAAC;IAC3B,mBAAmB,EAAE,SAAS,MAAM,EAAE,CAAC;CACxC;AAED,wBAAgB,cAAc,CAC5B,QAAQ,EAAE,mBAAmB,EAC7B,MAAM,EAAE,sBAAsB,GAC7B,iBAAiB,CAmCnB"}
|
|
@@ -25,6 +25,26 @@ export function renderTemplate(template, values) {
|
|
|
25
25
|
templateId: template.id,
|
|
26
26
|
files,
|
|
27
27
|
changes,
|
|
28
|
-
postGenerationNotes: template.postGenerationNotes ?? [],
|
|
28
|
+
postGenerationNotes: (template.postGenerationNotes ?? []).map((note) => substituteVariablePlaceholders(note, values)),
|
|
29
29
|
};
|
|
30
30
|
}
|
|
31
|
+
/**
|
|
32
|
+
* Replace `<varName>` placeholders in a note with the supplied values.
|
|
33
|
+
*
|
|
34
|
+
* Notes in template definitions are deliberately written with literal
|
|
35
|
+
* `<camel>` / `<name>` style placeholders so they remain readable as
|
|
36
|
+
* source. At render time we substitute against the user-supplied values
|
|
37
|
+
* so the rendered notes are directly actionable — the agent shouldn't
|
|
38
|
+
* have to mentally substitute its own variable names.
|
|
39
|
+
*
|
|
40
|
+
* Unknown placeholders (variables the user didn't supply) are left
|
|
41
|
+
* intact so the agent can still see which slot to fill.
|
|
42
|
+
*/
|
|
43
|
+
function substituteVariablePlaceholders(note, values) {
|
|
44
|
+
return note.replace(/<([A-Za-z_][A-Za-z0-9_]*)>/g, (match, name) => {
|
|
45
|
+
const v = values[name];
|
|
46
|
+
if (v === undefined || v === null)
|
|
47
|
+
return match;
|
|
48
|
+
return String(v);
|
|
49
|
+
});
|
|
50
|
+
}
|
package/package.json
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shrkcrft/templates",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.9",
|
|
4
4
|
"description": "SharkCraft templates: typed template definitions, registry, variable validation, rendering.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "SharkCraft contributors",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"main": "./dist/index.js",
|
|
9
|
-
"types": "./dist/index.d.
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
10
|
"exports": {
|
|
11
11
|
".": {
|
|
12
12
|
"types": "./dist/index.d.ts",
|
|
13
|
-
"bun": "./src/index.ts",
|
|
14
13
|
"import": "./dist/index.js",
|
|
15
14
|
"default": "./dist/index.js"
|
|
16
15
|
}
|
|
@@ -22,12 +21,12 @@
|
|
|
22
21
|
],
|
|
23
22
|
"repository": {
|
|
24
23
|
"type": "git",
|
|
25
|
-
"url": "git+https://github.com/
|
|
24
|
+
"url": "git+https://github.com/sharkcraft/sharkcraft.git",
|
|
26
25
|
"directory": "packages/templates"
|
|
27
26
|
},
|
|
28
|
-
"homepage": "https://github.com/
|
|
27
|
+
"homepage": "https://github.com/sharkcraft/sharkcraft",
|
|
29
28
|
"bugs": {
|
|
30
|
-
"url": "https://github.com/
|
|
29
|
+
"url": "https://github.com/sharkcraft/sharkcraft/issues"
|
|
31
30
|
},
|
|
32
31
|
"keywords": [
|
|
33
32
|
"sharkcraft",
|
|
@@ -43,7 +42,7 @@
|
|
|
43
42
|
"typecheck": "tsc --noEmit -p tsconfig.json"
|
|
44
43
|
},
|
|
45
44
|
"dependencies": {
|
|
46
|
-
"@shrkcrft/core": "^0.1.0-alpha.
|
|
45
|
+
"@shrkcrft/core": "^0.1.0-alpha.9"
|
|
47
46
|
},
|
|
48
47
|
"publishConfig": {
|
|
49
48
|
"access": "public"
|