seedproject-web/api/cli/resources.php
Carlos Arias 1f33296e30 feat: user auth (email + Google OAuth), Mailer, and CLI bridges
Generic framework features, code-only — the tables come from the schema snapshot:

- controllers/account.php — email signup (verified) + Google OAuth (server-side auth-code
  flow, async-popup friendly); native password_hash sessions on sp_users; sp_oauth_accounts +
  sp_user_tokens; PublicController origin+throttle guards; {ok,data,error} envelope.
- Helpers/Mailer.php — transactional email: Brevo HTTP API (Guzzle) -> SMTP fallback
  (PHPMailer) -> logs; config in sp_settings (encrypted).
- cli/rebuild.php — queue a static rebuild (sp_settings rebuild_pending flag) after DB edits.
- cli/resources.php — read a curated source registry (mde_resources) per agent_type.
- db/seed_google_oauth.php, db/seed_email.php — env-seeded encrypted secrets into sp_settings.
- templates/emails/verify.html — verification email template.
- composer.json — declare guzzlehttp/guzzle ^7.10 (account.php + Mailer use GuzzleHttp\Client).

Depends on the schema-snapshot branch (sp_users / sp_oauth_accounts / sp_user_tokens /
sp_settings / mde_resources) plus `composer require guzzlehttp/guzzle`. No data.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FMQeUnUrAeexcZ7P2Hxa6G
2026-07-11 09:14:25 -05:00

38 lines
1.2 KiB
PHP

<?php
/**
* Resource registry bridge for the content agents. Reads curated sources (mde_resources)
* per agent_type so the Node pipeline never needs DB creds.
*
* php api/cli/resources.php list <agent_type> -> JSON array of active resources
* php api/cli/resources.php touch <id> [<id>...] -> stamp last_used_at
*/
require __DIR__ . '/../vendor/autoload.php';
require __DIR__ . '/../config.php';
$cmd = $argv[1] ?? '';
if ($cmd === 'list') {
$type = $argv[2] ?? '';
if ($type === '') { fwrite(STDERR, "usage: resources.php list <agent_type>\n"); exit(1); }
$rows = \Db::select(
"SELECT resource_id, name, url, kind, notes, priority
FROM mde_resources
WHERE agent_type = ? AND active = 1
ORDER BY priority DESC, resource_id ASC",
[$type]
);
echo json_encode($rows, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
exit;
}
if ($cmd === 'touch') {
$ids = array_slice($argv, 2);
foreach ($ids as $id) {
\Db::execute("UPDATE mde_resources SET last_used_at = NOW() WHERE resource_id = ?", [(int) $id]);
}
echo json_encode(['ok' => true, 'touched' => count($ids)]);
exit;
}
fwrite(STDERR, "usage: resources.php list <agent_type> | touch <id...>\n");
exit(1);