Skip to content

Commit

Permalink
Placeholder for Extension:AI
Browse files Browse the repository at this point in the history
  • Loading branch information
edwardspec committed Dec 6, 2024
1 parent c4e5b2b commit d61bb0e
Show file tree
Hide file tree
Showing 10 changed files with 554 additions and 0 deletions.
54 changes: 54 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: JSON linter + luacheck

on: [push, pull_request, workflow_dispatch]

env:
DBTYPE: mysql
DBUSER: root

jobs:
# PHP linters: phpcs, parallel-lint, etc.
linter:
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
tools: composer
- uses: actions/cache@v4
with:
path: ~/.composer/cache
key: buildcache-linter
- run: sudo apt-get install -y composer && composer install
- run: composer test

# Phan (PHP static analyzer)
phan:
runs-on: ubuntu-22.04
env:
branch: REL1_39
steps:
- uses: actions/checkout@v4
- uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
extensions: ast
tools: composer
- uses: actions/cache@v4
with:
path: |
~/.composer/cache
buildcache
key: buildcache-phan
- uses: edwardspec/github-action-build-mediawiki@v1
with:
branch: ${{ env.branch }}
noinstall: 1
- name: Install dependencies
run: |
rsync -a --exclude buildcache --exclude mediawiki --exclude .git . mediawiki/extensions/AskAI/
cd mediawiki/extensions/AskAI
composer install
- name: RUN -- phan
run: cd mediawiki/extensions/AskAI && ./vendor/bin/phan --analyze-twice
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
vendor
3 changes: 3 additions & 0 deletions .phan/config.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<?php

return require __DIR__ . '/../vendor/mediawiki/mediawiki-phan-config/src/config.php';
11 changes: 11 additions & 0 deletions .phpcs.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0"?>
<ruleset>
<file>.</file>
<arg name="extensions" value="php,php5,inc" />
<arg name="encoding" value="UTF-8" />

<rule ref="./vendor/mediawiki/mediawiki-codesniffer/MediaWiki">
<!-- Don't want to apply this -->
<exclude name="MediaWiki.WhiteSpace.SpaceBeforeSingleLineComment.NewLineComment" />
</rule>
</ruleset>
339 changes: 339 additions & 0 deletions COPYING

Large diffs are not rendered by default.

25 changes: 25 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"require-dev": {
"php-parallel-lint/php-parallel-lint": "1.4.0",
"php-parallel-lint/php-console-highlighter": "1.0.0",
"mediawiki/minus-x": "1.1.3",
"mediawiki/mediawiki-codesniffer": "44.0.0",
"mediawiki/mediawiki-phan-config": "0.14.0"
},
"scripts": {
"test": [
"parallel-lint . --exclude vendor --exclude node_modules",
"minus-x check .",
"phpcs -p -s"
],
"fix": [
"minus-x fix .",
"phpcbf"
]
},
"config": {
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true
}
}
}
35 changes: 35 additions & 0 deletions extension.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
{
"name": "AskAI",
"version": "0.0.1",
"author": "Edward Chernenko",
"url": "https://www.mediawiki.org/wiki/Extension:AskAI",
"descriptionmsg": "askai-desc",
"license-name": "GPL-2.0+",
"requires": {
"MediaWiki": ">= 1.39.0"
},
"type": "other",
"AutoloadClasses": {
"MediaWiki\\AskAI\\SpecialAI": "includes/SpecialAI.php"
},
"MessagesDirs": {
"AskAI": [
"i18n"
]
},
"config": {
"AskAIService": {
"description": "Parameters of the external AI service.",
"value": {
"type": "openai",
"apiUrl": "https://api.openai.com/v1/chat/completions",
"model": "gpt-3.5-turbo"
}
},
"AskAIApiKey": {
value: "",
description: "API key for the external AI service."
}
},
"manifest_version": 2
}
9 changes: 9 additions & 0 deletions i18n/en.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"@metadata": {
"authors": [
"Edward Chernenko"
]
},

"askai-desc": "Provides [[Special:AI]], which allows user to make AI queries about content of articles in this wiki."
}
9 changes: 9 additions & 0 deletions i18n/qqq.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"@metadata": {
"authors": [
"Edward Chernenko"
]
},

"askai-desc": "{{desc|name=AskAI|url=https://www.mediawiki.org/wiki/Extension:AskAI}}"
}
68 changes: 68 additions & 0 deletions includes/SpecialAI.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<?php

/**
* Implements AskAI extension for MediaWiki.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* http://www.gnu.org/copyleft/gpl.html
*
* @file
*/

namespace MediaWiki\AskAI;

use FormSpecialPage;
use MediaWiki\HTMLForm\HTMLForm;

/**
* Implements [[Special:AI]].
*/
class SpecialAI extends FormSpecialPage {
public function __construct() {
parent::__construct( 'AI', 'askai' );
}

public function requiresWrite() {
return false;
}

/** @inheritDoc */
protected function getFormFields() {
return [
];
}

/** @inheritDoc */
protected function alterForm( HTMLForm $form ) {
}

/** @inheritDoc */
public function onSubmit( array $data ) {
return Status::newGood();
}

public function onSuccess() {
}

/** @inheritDoc */
protected function getDisplayFormat() {
return 'ooui';
}

/** @inheritDoc */
protected function getGroupName() {
return 'wiki';
}
}

0 comments on commit d61bb0e

Please sign in to comment.