event 223 solution

This commit is contained in:
elffuss-bot
2026-10-02 06:52:45 +00:00
parent 6b408d52ed
commit 4c59ecbe36
2 changed files with 76 additions and 0 deletions

View File

@@ -0,0 +1,75 @@
diff --git a/tests/acceptance/5/CRITERIA.json b/tests/acceptance/5/CRITERIA.json
new file mode 100644
index 0000000000000000000000000000000000000000..e9eba524d08705b55cc01ae8d3dcf5a58c68978b
--- /dev/null
+++ b/tests/acceptance/5/CRITERIA.json
@@ -0,0 +1,24 @@
+{
+ "schema": "elffuss-t2t/criteria@2",
+ "issue": 5,
+ "criteria": [
+ {
+ "index": 1,
+ "tests": [
+ "tests/acceptance/5/criteria.test.js::criterion 1"
+ ]
+ },
+ {
+ "index": 2,
+ "tests": [
+ "tests/acceptance/5/criteria.test.js::criterion 2"
+ ]
+ },
+ {
+ "index": 3,
+ "tests": [
+ "tests/acceptance/5/criteria.test.js::criterion 3"
+ ]
+ }
+ ]
+}
diff --git a/tests/acceptance/5/criteria.test.js b/tests/acceptance/5/criteria.test.js
new file mode 100644
index 0000000000000000000000000000000000000000..5794ff47df37b11d316123ee0b0db4ea7037d4c8
--- /dev/null
+++ b/tests/acceptance/5/criteria.test.js
@@ -0,0 +1,20 @@
+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" }`.
+ assert.deepEqual(mod.parseSkill("---\r\nname: demo\r\ndescription: x\r\n---\r\nBody"), { name: "demo", description: "x", content: "Body" })
+})
+
+test('criterion 2', () => {
+ // `parseSkill("---\nname: demo\ndescription: x\n---\nBody")` returns `{ name: "demo", description: "x", content: "Body" }`.
+ assert.deepEqual(mod.parseSkill("---\nname: demo\ndescription: x\n---\nBody"), { name: "demo", description: "x", content: "Body" })
+})
+
+test('criterion 3', () => {
+ // `parseSkill("Body only", "fallback")` returns `{ name: "fallback", description: "", content: "Body only" }`.
+ assert.deepEqual(mod.parseSkill("Body only", "fallback"), { name: "fallback", description: "", content: "Body only" })
+})
diff --git a/web/js/skills.js b/web/js/skills.js
index 6effe6b048d4fae299dde849d65d3cf9aae13de5..45d80c273c88ff5648fa3522df9a68660eb198d1 100644
--- a/web/js/skills.js
+++ b/web/js/skills.js
@@ -131,11 +131,12 @@ export async function installFromRepo(entry) {
// SKILL.md → { name, description, content }
export function parseSkill(md, fallbackName = 'skill') {
- const fm = md.match(/^---\n([\s\S]*?)\n---/);
+ 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();
- const content = md.replace(/^---\n[\s\S]*?\n---\n?/, '').trim();
+ const content = normalizedMd.replace(/^---\n[\s\S]*?\n---\n?/, '').trim();
return { name, description, content };
}

1
events/0000000223.json Normal file
View File

@@ -0,0 +1 @@
{"data":{"cites":[],"envelope":{"delegation":{"identity":"0xe0425bed061809c5ce17450fe47dc970090a0938","nonce":"1790923270","project":"0x0000000000000000000000000000000000000000000000000000000000000000","scopes":3,"sessionX":"0x965ee667b228d5242d2d86989eea6d4879c4ad1de748a7bcae861f2baff69398","sessionY":"0x4109e51c15fd0376e2f76a2b5cf293cdf9fb69f7ac1f617c13ddbb117fe34669","validFrom":"1790923270","validUntil":"1791528070"},"delegationSignature":"0x4322f7ca1df9e93982471f2e75c20c605df23e92aa5da74809aeaa8fc498579623912c8227ebe106c0529f958b988700ce2aa17a2667ef65de01df41d39cc5261c","kind":"session","signature":"0xf8f4ab35bf201bc9b85d361859bf1a3d9041dca2ab90a90763c09ee9a9a8889e5c084943c94cbb036813ef963cd8f3d1b727c9451677d5c32780045b92d4e3b6"},"mainHead":null,"message":{"author":"0xe0425bed061809c5ce17450fe47dc970090a0938","baseCommit":"0x42a4a9a67cda0da050ec0e73e6294537cce1e541","basePartial":"0x0000000000000000000000000000000000000000000000000000000000000000","citesHash":"0x0000000000000000000000000000000000000000000000000000000000000000","issueId":"0xce1f03063035e40185e7b2778dce2cf95081649b1257ecb171218cf78a9dda3c","issuedAt":"1790923964","lines":5,"nonce":"1790923964000","patchHash":"0x4657064e984fe26edc0890b73bec2ed2cef47df729a2ca02c9b7027826578f8e","project":"0x16d6e75341c5f21003a4d9e89b416a545f7335094d7df139fd20942c9b7fb2de","repo":"0xd822e541c0173492ca0725a08935bcd8eaa756a9559600a9427d0daac625ead2"},"pr":"elffuss/code:item/0x2a7b6a284a867d4e10849050698c3956c5f7840a3bc29190fc7798287e6da0b9"},"eventHash":"0xf6023d884468349736c2b2a3a9b9e97e595338164d94ffd4f154f4a95cf6bae9","gatewaySignature":"0xde598830b41c7be42a6ad5ac0d688898debfe683ceaf64de5dc7f988e5bf4584675138cd5b5dd9a1241d521f104a02a536b6c15487ac8a8cd436782172c89c8c1b","prev":"0x5cfe80fa08d8560b561ea47a6d2d16105f96ae6e53e15696e4a547959fa8c2c9","seq":223,"ts":1790923965,"type":"solution","v":2}