Skip to content

[demo] compile-to-markdown-skill#6

Open
tkukurin wants to merge 6 commits into
mainfrom
tk/compile-02
Open

[demo] compile-to-markdown-skill#6
tkukurin wants to merge 6 commits into
mainfrom
tk/compile-02

Conversation

@tkukurin
Copy link
Copy Markdown
Owner

@tkukurin tkukurin commented Apr 27, 2026

Compiling or reverse of compiling?

# "Compiled" skill

Cross-check parser extractions against the raw text.

> You are a calendar booking verifier.
Input JSON has "text" (original request) and "prior_steps" (each parser's
name/description/value/metadata). Cross-check the prior findings against
the text: confirm, correct, fill gaps (no invention), flag ambiguity.

Return ONLY JSON:
{
  "booking": {"weekday": ..., "start": ..., "end": ..., "minutes": ..., "topic": ...},
  "notes": "<one sentence>"
}


## λ::weekday

Find an explicit weekday name (Monday..Sunday).

```python
def parse_weekday(text):
    text = text.lower()
    for day in WEEKDAYS:
        if re.search(f'\\b{day}\\b', text):
            return {'value': day.capitalize(), 'metadata': {'reason': 'matched'}}
    return {'value': None, 'metadata': {'reason': 'no_weekday'}}
```

## λ::time

Find a clock time like '3pm', '15:00', or a range '9-10am'.

```python
def parse_time(text):
    m = _TIME_RE.search(text)
    if not m:
        return {'value': None, 'metadata': {'reason': 'no_time'}}
    h1, min1, h2, min2, ampm = m.groups()
    start = _fmt(int(h1), int(min1 or 0), ampm)
    end = _fmt(int(h2), int(min2 or 0), ampm) if h2 else None
    return {'value': {'start': start, 'end': end}, 'metadata': {'range': bool(end)}}
```

## λ::duration

Find a duration phrase like '30 minutes' or '2 hrs' and return minutes.

```python
def parse_duration(text):
    m = _DUR_RE.search(text)
    if not m:
        return {'value': None, 'metadata': {'reason': 'no_duration'}}
    n, unit = (float(m.group(1)), m.group(2).lower())
    minutes = int(n * 60) if unit.startswith(('hour', 'hr')) else int(n)
    return {'value': minutes, 'metadata': {'reason': 'matched'}}
```

## λ::topic

Find a topic phrase introduced by 'about' or 're:'.

```python
def parse_topic(text):
    m = _TOPIC_RE.search(text)
    if not m:
        return {'value': None, 'metadata': {'reason': 'no_topic'}}
    return {'value': m.group(1).strip(), 'metadata': {'reason': 'matched'}}
```

Example A/B test

Propmt: can we meet on Tuesday at 3pm for 30 mins about the Q4 review?

Programmatic (run_skill)

{
  "weekday": "Tuesday",
  "start": "15:00",
  "end": "15:30",
  "minutes": 30,
  "topic": "the Q4 review"
}
  resolved_by: ('book_meeting',)
  notes: All elements of the booking have been confirmed.

Compiled (skill.md + tool calling)

{
  "booking": {
    "weekday": "Tuesday",
    "start": "3:00pm",
    "end": null,
    "minutes": 30,
    "topic": "the Q4 review"
  },
  "notes": "All details matched the request."
}

EDIT TIL: nest markdown with 4 backticks

- rewrite_step_source: AST rewriter strips ctx/StepResult boilerplate
- compile_skill: flattens tree, deterministic → code, LLM → prose
- compile_vs_run: side-by-side run_skill vs compiled md + tool calling
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant