Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions .agents/skills/create-issue/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
---
name: create-issue
description: Create a well-structured GocciaScript GitHub issue from a tagline or short description, using the repository issue template and project issue style. Use when the user enters /create-issue.
disable-model-invocation: true
---

# Create Issue

Create a GitHub issue from the user's tagline or short description.

## Steps

1. Parse the user's tagline or short description from the command arguments. If it is missing, ask for it.
2. Read `.github/ISSUE_TEMPLATE/default.md`.
3. Use the established GocciaScript issue style. Good issues in this repo typically include:
- A specific, plain-language title without an area prefix.
- A short problem summary.
- Reproduction commands or a minimal code sample for bugs.
- Current behavior and expected behavior.
- Spec context or project context when relevant.
- Test impact, blocked tests, or user impact.
- Likely fix area, scope notes, constraints, and related issues.
4. Investigate the codebase enough to avoid creating a vague or duplicate issue. Search for related code, docs, tests, and existing issues. If the tagline cannot be turned into a concrete issue without guessing, ask clarifying questions.
5. Draft the issue using the repository template. Preserve the template's headings unless another project issue pattern is clearly more appropriate for the issue type.
6. Choose labels by matching existing project label conventions. Use labels, not title prefixes, to capture area and type. Do not invent new labels unless the user asks.
7. Show the title, labels, and body draft to the user before creating the issue unless the user explicitly asked to create it without review.
8. Create the issue with GraphQL first. Include `labelIds` only when labels were selected:

```bash
gh api graphql \
-f query='mutation($repositoryId:ID!, $title:String!, $body:String!, $labelIds:[ID!]) {
createIssue(input: {
repositoryId: $repositoryId,
title: $title,
body: $body,
labelIds: $labelIds
}) {
issue { url number }
}
}' \
-F repositoryId="$REPOSITORY_ID" \
-f title="$ISSUE_TITLE" \
-f body="$ISSUE_BODY"
```

When labels were selected, append one `-F labelIds[]="$LABEL_ID"` argument per label ID.

9. If GraphQL is rate-limited or unavailable, create the issue with REST:

```bash
gh api "repos/$OWNER/$REPO/issues" \
-f title="$ISSUE_TITLE" \
-f body="$ISSUE_BODY" \
--jq '.html_url'
```
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved

When labels were selected, append one `-f labels[]="$LABEL_NAME"` argument per label name.

10. Return the issue URL to the user.
59 changes: 59 additions & 0 deletions .agents/skills/create-pr/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
---
name: create-pr
description: Commit relevant changes, push the branch, and create a GocciaScript pull request using the repository PR template. Use when the user enters /create-pr.
disable-model-invocation: true
---

# Create PR

This command is explicit permission to commit relevant changes, push the branch, and create a pull request.

## Steps

1. Inspect the repository state:
- `git status --short --branch`
- `git diff`
- `git diff --staged`
- `git log --oneline -5`
2. Confirm there are changes to commit. If there are none, stop.
3. If the current branch is `main`, create a focused branch before committing. Use an issue number or change summary for the branch name when available; otherwise ask the user.
4. Stage only relevant files. Exclude secrets and unrelated user changes.
5. Commit with a concise message passed via HEREDOC.
6. Push the branch with upstream tracking when needed: `git push -u origin HEAD`.
7. Build the PR body from the repository's pull request template. Read `.github/pull_request_template.md`, or the relevant template under `.github/PULL_REQUEST_TEMPLATE/` if the repository uses multiple templates. Fill the template faithfully and preserve its structure.
8. Create the pull request with GraphQL first:

```bash
gh api graphql \
-f query='mutation($repositoryId:ID!, $base:String!, $head:String!, $title:String!, $body:String!) {
createPullRequest(input: {
repositoryId: $repositoryId,
baseRefName: $base,
headRefName: $head,
title: $title,
body: $body
}) {
pullRequest { url number }
}
}' \
-F repositoryId="$REPOSITORY_ID" \
-f base="$BASE_BRANCH" \
-f head="$HEAD_BRANCH" \
-f title="$PR_TITLE" \
-f body="$PR_BODY"
```

9. If GraphQL is rate-limited or unavailable, create the pull request with REST:

```bash
gh api "repos/$OWNER/$REPO/pulls" \
-f title="$PR_TITLE" \
-f head="$HEAD_BRANCH" \
-f base="$BASE_BRANCH" \
-f body="$PR_BODY" \
--jq '.html_url'
```

10. Return the PR URL to the user.

Do not skip git hooks or verification unless the user explicitly asks.
35 changes: 35 additions & 0 deletions .agents/skills/implement-issue/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
---
name: implement-issue
description: Validate a GitHub issue against the GocciaScript codebase, present implementation options, implement the chosen fix, and prepare a PR. Use when the user enters /implement-issue with an issue number.
disable-model-invocation: true
---

# Implement Issue

Validate and implement the requested GitHub issue.

## Steps

1. Parse the issue number. If it is missing or not numeric, ask the user for the issue number.
2. Fetch the issue with GraphQL first, including title, body, state, labels, assignees, URL, comments, and whether the issue is actually a pull request.
3. If GraphQL is rate-limited or unavailable, fetch the issue with REST:

```bash
gh api "repos/$OWNER/$REPO/issues/$ISSUE_NUMBER"
```

4. Thoroughly review and validate the issue before coding:
- The issue exists.
- The issue is open.
- The issue is not a pull request.
- Labels or comments do not indicate `blocked`, `duplicate`, `wontfix`, or equivalent.
- The reported behavior has been checked against the current codebase, not just accepted from the issue text.
- The problem statement is verified as an actual issue in this codebase by reading the relevant implementation, running or adding a focused reproduction when practical, and comparing observed behavior with the expected behavior.
- The expected behavior and acceptance criteria are clear enough to implement.
5. If validation fails or requirements are ambiguous, stop and ask the user.
6. Present the user with different implementation options, including tradeoffs, recommended verification, and the option you recommend. Do not code until the user chooses an option or explicitly asks you to proceed with the recommendation.
7. Check whether a focused branch or worktree for the issue already exists locally or on `origin`. Prefer reusing the existing focused worktree when present. If a branch exists without a worktree, use or create a worktree for it when that best isolates the work. If no focused branch exists, create one named from the issue, for example `issue-123-short-slug`, and use a worktree when practical.
8. Implement the smallest complete change that satisfies the chosen approach.
9. Add or update tests and documentation according to `CONTRIBUTING.md`.
10. Run targeted verification, then broader verification when the change has wider impact.
11. Finish by running the `/create-pr` workflow. Include `Closes #<number>` in the PR body.
19 changes: 19 additions & 0 deletions .agents/skills/review-pr/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
name: review-pr
description: Resolve review comments on the current GocciaScript pull request without posting top-level PR comments. Use when the user enters /review-pr.
disable-model-invocation: true
---

# Review PR

Resolve review comments on the current PR by following `.agents/skills/resolve-reviews/SKILL.md`, with these project-specific overrides.

## Rules

- Do not leave top-level PR comments, PR review summaries, or issue comments.
- Replies to existing review comments or review threads are allowed when needed to resolve those comments.
- Keep the final summary in chat unless the user explicitly asks to post it to GitHub.
- Preserve unrelated work in the working tree. Do not revert changes you did not make.
- Run relevant verification before committing review fixes.

Avoid commands that create top-level comments, including `gh pr comment`, REST issue comment endpoints, or a review body that is not tied to an existing thread.
38 changes: 38 additions & 0 deletions .agents/skills/update-pr/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
---
name: update-pr
description: Commit relevant local changes and push them to the current GocciaScript pull request branch. Use when the user enters /update-pr.
disable-model-invocation: true
---

# Update PR

This command is explicit permission to commit relevant changes and push them to the current PR branch.

## Steps

1. Inspect the repository state:
- `git status --short --branch`
- `git diff`
- `git diff --staged`
- `git log --oneline -5`
2. Confirm the current branch is not `main`. If it is `main`, stop and ask for the intended PR branch.
3. Confirm the branch has an associated PR with `gh pr view`. If there is no PR, ask whether to run `/create-pr` instead.
4. Confirm there are changes to commit. If there are none, stop.
5. Stage only relevant files. Exclude secrets and unrelated user changes.
6. Commit with a concise message passed via HEREDOC.
7. Push the branch, setting upstream tracking if needed:

```bash
git push -u origin HEAD
```

8. Review the current PR title and body against the latest implementation:
- Read `.github/pull_request_template.md`, or the relevant template under `.github/PULL_REQUEST_TEMPLATE/` if the repository uses multiple templates.
- Fetch the PR body with `gh pr view --json body,url,title`.
- Compare the title, Summary, Testing, linked issues, and any scope notes with the actual commits and verification just performed.
- If the title is stale, too narrow, or no longer matches the implementation, update it with `gh pr edit --title "$PR_TITLE"`.
- If the body is stale, incomplete, or no longer matches the implementation, update it with `gh pr edit --body-file <file>`.
- Preserve the repository pull request template structure and avoid removing useful reviewer context.
9. Report the commit hash, pushed branch, PR URL, whether the PR title or body was updated, and verification performed.

Do not skip git hooks or verification unless the user explicitly asks.
1 change: 1 addition & 0 deletions .claude/skills
1 change: 1 addition & 0 deletions .markdownlint-cli2.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"**/node_modules/**",
"CHANGELOG.md",
".agents/skills/**",
".claude/**",
"website/content/docs/**",
// Claude Code @-include shim files — single-line `@OTHER.md` directives
// that aren't real markdown.
Expand Down
6 changes: 6 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ When your change affects behavior visible to users or contributors, update the r

`docs/` files are about the GocciaScript project (engine, language, runtime). Contributing guides are about FreePascal contribution standards. Match the voice and structure of the target document.

## Implementation principles

- **Prefer modifying existing code** — Update, simplify, or replace the existing implementation before adding parallel code paths or new helpers.
- **Simplify and centralize** — Keep the smallest complete implementation. When the same logic is needed more than once, centralize it so behavior, validation, and error formatting do not drift. Centralization must follow the existing architecture, ownership boundaries, and project patterns in [Architecture](docs/architecture.md), [Core Patterns](docs/core-patterns.md), and [Code Style](docs/contributing/code-style.md); do not create a new abstraction that cuts across those boundaries without a clear design reason.
- **Verify against the official spec** — For ECMAScript behavior, check the current official ECMA-262 text before implementing or reviewing semantics. Use spec comments as described in [Code Style](docs/contributing/code-style.md#ecmascript-spec-annotations), but do not treat comments as a substitute for reading the spec. When behavior is ambiguous or bug reports appear to conflict with the spec, compare against other JavaScript engine implementations such as V8, SpiderMonkey, JavaScriptCore, or Node.js before deciding the expected behavior.

## Critical rules

These rules **must** be followed when modifying the codebase:
Expand Down
6 changes: 3 additions & 3 deletions docs/contributing/workflow.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
## Executive Summary

- **Local setup** — Install Lefthook for pre-commit formatting, then `lefthook install`
- **Branch workflow** — Branch from `main`, implement with [critical rules](../../CONTRIBUTING.md#critical-rules) and [code style](code-style.md), add tests, update docs, commit
- **Branch workflow** — Branch from `main`, implement with [implementation principles](../../CONTRIBUTING.md#implementation-principles), [critical rules](../../CONTRIBUTING.md#critical-rules), and [code style](code-style.md), add tests, update docs, commit
- **Verification** — `./build.pas testrunner && ./build/GocciaTestRunner tests` before every push

## Local setup
Expand Down Expand Up @@ -50,8 +50,8 @@ Formatting, editor integration, and CI behavior are covered in [Tooling](tooling
Every change should follow this sequence:

1. **Create a branch** from `main` with a descriptive name (for example `feature/string-prototype-repeat`, `fix/nan-comparison`).
2. **Implement** on that branch, following [Critical rules](../../CONTRIBUTING.md#critical-rules) and [Code style](code-style.md).
3. **Annotate spec references** — For ECMAScript behavior, add `// ESYYYY` spec comments as described in [ECMAScript spec annotations](code-style.md#ecmascript-spec-annotations).
2. **Implement** on that branch, following [Implementation principles](../../CONTRIBUTING.md#implementation-principles), [Critical rules](../../CONTRIBUTING.md#critical-rules), [Code style](code-style.md), and the relevant architecture docs for the area you touch.
3. **Verify and annotate spec references** — For ECMAScript behavior, verify semantics against the current official ECMA-262 text, then add `// ESYYYY` spec comments as described in [ECMAScript spec annotations](code-style.md#ecmascript-spec-annotations).
4. **Add or update tests** — JavaScript tests under `tests/` are primary; Pascal units under `source/units/*.Test.pas` when you touch AST, evaluator, or value types. See [testing.md](../testing.md) and [Critical rules](../../CONTRIBUTING.md#critical-rules).
5. **Update documentation** that your change affects (`README.md`, `docs/*`, and CONTRIBUTING.md when workflow, rules, or style change). Edit **AGENTS.md** only when **agent-specific** guidance changes—not to duplicate CONTRIBUTING. If the change introduces a new **architectural or design decision** (not just a feature addition), add an entry to [decision-log.md](../decision-log.md) following the template there.
6. **Commit** with a clear message. Do not commit directly to `main`.
Expand Down
2 changes: 1 addition & 1 deletion scripts/check-doc-duplication.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ const NUM_HASHES = 128;
const NUM_BANDS = 32;
const ROWS_PER_BAND = NUM_HASHES / NUM_BANDS; // 4
const EXTENSIONS = new Set([".md", ".mdx"]);
const IGNORE_DIRS = new Set(["node_modules", ".git", ".agents", "dist", "build", ".next", "vendor"]);
const IGNORE_DIRS = new Set(["node_modules", ".git", ".agents", ".claude", "dist", "build", ".next", "vendor"]);
// Build artifacts whose contents are synced from elsewhere and validated at
// the source location. Path-prefix matched against repo-relative paths.
const IGNORE_PATH_PREFIXES = ["website/content/docs/"];
Expand Down
2 changes: 1 addition & 1 deletion scripts/check-doc-length.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const ROOT = join(__dirname, "..");
const DEFAULT_LIMIT = parseInt(process.env.DOC_LENGTH_LIMIT ?? "800", 10);
const VERBOSE = process.argv.includes("--verbose");
const EXTENSIONS = new Set([".md", ".mdx"]);
const IGNORE_DIRS = new Set(["node_modules", ".git", "dist", "build", ".next", "vendor"]);
const IGNORE_DIRS = new Set(["node_modules", ".git", ".agents", ".claude", "dist", "build", ".next", "vendor"]);
// Build artifacts whose contents are synced from elsewhere and validated at
// the source location. Path-prefix matched against repo-relative paths.
const IGNORE_PATH_PREFIXES = ["website/content/docs/"];
Expand Down
2 changes: 1 addition & 1 deletion scripts/check-doc-links.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const __dirname = dirname(fileURLToPath(import.meta.url));
const ROOT = join(__dirname, "..");
const VERBOSE = process.argv.includes("--verbose");
const EXTENSIONS = new Set([".md", ".mdx"]);
const IGNORE_DIRS = new Set(["node_modules", ".git", "dist", "build", ".next", "vendor"]);
const IGNORE_DIRS = new Set(["node_modules", ".git", ".agents", ".claude", "dist", "build", ".next", "vendor"]);
// Build artifacts whose contents are synced from elsewhere and validated at
// the source location. Path-prefix matched against repo-relative paths.
const IGNORE_PATH_PREFIXES = ["website/content/docs/"];
Expand Down
Loading