event 616 solution
This commit is contained in:
@@ -0,0 +1,53 @@
|
||||
diff --git a/tests/acceptance/11/CRITERIA.json b/tests/acceptance/11/CRITERIA.json
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..a9f33b0ac2ee4f747dde22303269839bec7596d2
|
||||
--- /dev/null
|
||||
+++ b/tests/acceptance/11/CRITERIA.json
|
||||
@@ -0,0 +1,12 @@
|
||||
+{
|
||||
+ "schema": "elffuss-t2t/criteria@2",
|
||||
+ "issue": 11,
|
||||
+ "criteria": [
|
||||
+ {
|
||||
+ "index": 1,
|
||||
+ "tests": [
|
||||
+ "tests/acceptance/11/criteria.test.js::criterion 1"
|
||||
+ ]
|
||||
+ }
|
||||
+ ]
|
||||
+}
|
||||
diff --git a/tests/acceptance/11/criteria.test.js b/tests/acceptance/11/criteria.test.js
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..299a05e182cf324d834ed28f25fb37900d035158
|
||||
--- /dev/null
|
||||
+++ b/tests/acceptance/11/criteria.test.js
|
||||
@@ -0,0 +1,14 @@
|
||||
+import { test } from 'node:test'
|
||||
+import assert from 'node:assert/strict'
|
||||
+import { readFileSync } from 'node:fs'
|
||||
+import * as mod from '../../../web/js/skills.js' // the code under test: call it as mod.<name>(...)
|
||||
+const source = readFileSync(new URL('../../../web/js/skills.js', import.meta.url), 'utf8') // the text of web/js/skills.js, for a criterion about how the file is written
|
||||
+
|
||||
+test('criterion 1', () => {
|
||||
+ // `parseSkill("---\r\nname: demo\r\ndescription: x\r\n---\r\nBody")` returns `{ name: "demo", description: "x", content: "Body" }`, and still returns `{ name: "fallback", description: "", content: "Body only" }`
|
||||
+ const result1 = mod.parseSkill("---\r\nname: demo\r\ndescription: x\r\n---\r\nBody")
|
||||
+ assert.deepStrictEqual(result1, { name: "demo", description: "x", content: "Body" })
|
||||
+
|
||||
+ const result2 = mod.parseSkill("Body only", "fallback")
|
||||
+ assert.deepStrictEqual(result2, { name: "fallback", description: "", content: "Body only" })
|
||||
+})
|
||||
diff --git a/web/js/skills.js b/web/js/skills.js
|
||||
index 6effe6b048d4fae299dde849d65d3cf9aae13de5..9e810f25afc174bd6b66283002faff07c9c8a94a 100644
|
||||
--- a/web/js/skills.js
|
||||
+++ b/web/js/skills.js
|
||||
@@ -130,8 +130,8 @@ export async function installFromRepo(entry) {
|
||||
}
|
||||
|
||||
// SKILL.md → { name, description, content }
|
||||
-export function parseSkill(md, fallbackName = 'skill') {
|
||||
- const fm = md.match(/^---\n([\s\S]*?)\n---/);
|
||||
+export function parseSkill(md, fallbackName = 'skill') { const normalizedMd = md.replace(/\r\n/g, '\n');
|
||||
+ const fm = normalizedMd.match(/^---\n([\s\S]*?)\n---/);
|
||||
const meta = fm?.[1] || '';
|
||||
const name = meta.match(/^name:\s*(.+)$/m)?.[1]?.trim() || fallbackName;
|
||||
const description = (meta.match(/^description:\s*([\s\S]+?)(?:\n\w+:|$)/m)?.[1] || '').replace(/\s+/g, ' ').trim();
|
||||
1
events/0000000616.json
Normal file
1
events/0000000616.json
Normal file
@@ -0,0 +1 @@
|
||||
{"data":{"cites":[],"envelope":{"delegation":{"identity":"0x082ae053d1230072f2fc61d3e9aa22ff017b9f30","nonce":"1790928362","project":"0x0000000000000000000000000000000000000000000000000000000000000000","scopes":3,"sessionX":"0x6b5e37ebedb75c4a7c6a439f2d16a6c6421340403002e5ca1d8615299cb4f98a","sessionY":"0xca75eecacb48bf2798cd9f8b8cd5649247dde0dfe76ccb8d0087406431e469e0","validFrom":"1790928362","validUntil":"1791533162"},"delegationSignature":"0x0de3ef7107ef0afe05d7465fc027519d4fca9940765473a5f20d594c0f441b3341db92b69dc86c68b3690b31c18c7b46c1499ef2752d8aca9e2a3b17d8c5d64b1c","kind":"session","signature":"0xdfd7c5dffc89ef98124fb3132255c3d3331dfee602b9b9fb1b24626fdc2025b8210d839e84e811f9705d08655f25c009f49a228630858f88ad5690d07baa3d2e"},"mainHead":null,"message":{"author":"0x082ae053d1230072f2fc61d3e9aa22ff017b9f30","baseCommit":"0x42a4a9a67cda0da050ec0e73e6294537cce1e541","basePartial":"0x0000000000000000000000000000000000000000000000000000000000000000","citesHash":"0x0000000000000000000000000000000000000000000000000000000000000000","issueId":"0x33958ef2cc4d93a93649833be3a29f2b76bbd4080db691cff2473389671a252e","issuedAt":"1790931450","lines":4,"nonce":"1790931450000","patchHash":"0x4f4a4643f71894ac25b44c90d59d9f33693484a9cc9361cb1a8b577c5d3bf482","project":"0x16d6e75341c5f21003a4d9e89b416a545f7335094d7df139fd20942c9b7fb2de","repo":"0xd822e541c0173492ca0725a08935bcd8eaa756a9559600a9427d0daac625ead2"},"pr":"elffuss/code:item/0x9f38af9befefbb710877f338f275274ecc1cd75e8040c5af0966b18130d42063"},"eventHash":"0x50d808363e9991a1e10b119b3a0866d7e2d05c124f669392b8553b73c27d91aa","gatewaySignature":"0x6fa67fa694b6cab98fc6293447534e1d88a42c0c88f50e156d928defb57b354d38f461f9620d5a5fffdb5e41f7b0cbe8ed4aef283d0e49e033c041df6209c49d1b","prev":"0xf829ff4a8e5b556313c418562782e01a28691d1fb41a4fc022f962d574ba4386","seq":616,"ts":1790931451,"type":"solution","v":2}
|
||||
Reference in New Issue
Block a user