Convert gitgram/ and aitimemachine/ from embedded git repos (which showed as opaque submodule gitlinks on GitHub) into fully-tracked first-party content. AITM now merges its 7 vendored repos as first-party engines: - memory: beads (Go task DAG) + context7 (docs SDK), unified into saved_contexts - git: vendored C git (bundled binary) + gitnexus (in-process code intelligence) - agentic: a2a (@a2a-js/sdk) + pal (AITM-managed Python subprocess) Includes the full session's product build: Gitgram web/mobile/backend features, AITM website/CLI/MCP, the unified memory layer, engine build tooling (scripts/build-engines.sh, Dockerfile, CI), docs (README, ENGINES.md, ARCHITECTURE.md), and extensive test suites. Build artifacts, node_modules, external/, and gemini-cli are gitignored. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
103 lines
3.3 KiB
Go
103 lines
3.3 KiB
Go
package issueops
|
|
|
|
import (
|
|
"context"
|
|
"database/sql"
|
|
"fmt"
|
|
"strings"
|
|
)
|
|
|
|
// SetConfigInTx sets a configuration value within an existing transaction.
|
|
// Normalizes issue_prefix by stripping trailing hyphens.
|
|
func SetConfigInTx(ctx context.Context, tx DBTX, key, value string) error {
|
|
if key == "issue_prefix" {
|
|
value = strings.TrimSuffix(value, "-")
|
|
}
|
|
_, err := tx.ExecContext(ctx, "REPLACE INTO config (`key`, value) VALUES (?, ?)", key, value)
|
|
if err != nil {
|
|
return fmt.Errorf("set config %s: %w", key, err)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// GetConfigInTx retrieves a configuration value within an existing transaction.
|
|
// Returns ("", nil) if the key does not exist.
|
|
func GetConfigInTx(ctx context.Context, tx DBTX, key string) (string, error) {
|
|
var value string
|
|
err := tx.QueryRowContext(ctx, "SELECT value FROM config WHERE `key` = ?", key).Scan(&value)
|
|
if err == sql.ErrNoRows {
|
|
return "", nil
|
|
}
|
|
if err != nil {
|
|
return "", fmt.Errorf("get config %s: %w", key, err)
|
|
}
|
|
return value, nil
|
|
}
|
|
|
|
// GetAllConfigInTx retrieves all configuration key-value pairs within an existing transaction.
|
|
func GetAllConfigInTx(ctx context.Context, tx DBTX) (map[string]string, error) {
|
|
rows, err := tx.QueryContext(ctx, "SELECT `key`, value FROM config")
|
|
if err != nil {
|
|
return nil, fmt.Errorf("get all config: %w", err)
|
|
}
|
|
defer rows.Close()
|
|
|
|
result := make(map[string]string)
|
|
for rows.Next() {
|
|
var k, v string
|
|
if err := rows.Scan(&k, &v); err != nil {
|
|
return nil, fmt.Errorf("get all config: scan: %w", err)
|
|
}
|
|
result[k] = v
|
|
}
|
|
return result, rows.Err()
|
|
}
|
|
|
|
// SetMetadataInTx sets a metadata value within an existing transaction.
|
|
func SetMetadataInTx(ctx context.Context, tx DBTX, key, value string) error {
|
|
_, err := tx.ExecContext(ctx, "REPLACE INTO metadata (`key`, value) VALUES (?, ?)", key, value)
|
|
if err != nil {
|
|
return fmt.Errorf("set metadata %s: %w", key, err)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// GetMetadataInTx retrieves a metadata value within an existing transaction.
|
|
// Returns ("", nil) if the key does not exist.
|
|
func GetMetadataInTx(ctx context.Context, tx DBTX, key string) (string, error) {
|
|
var value string
|
|
err := tx.QueryRowContext(ctx, "SELECT value FROM metadata WHERE `key` = ?", key).Scan(&value)
|
|
if err == sql.ErrNoRows {
|
|
return "", nil
|
|
}
|
|
if err != nil {
|
|
return "", fmt.Errorf("get metadata %s: %w", key, err)
|
|
}
|
|
return value, nil
|
|
}
|
|
|
|
// SetLocalMetadataInTx sets a value in the dolt-ignored local_metadata table
|
|
// within an existing transaction. Used for clone-local state that should not
|
|
// generate merge conflicts (tip timestamps, version stamps, sync cursors).
|
|
func SetLocalMetadataInTx(ctx context.Context, tx DBTX, key, value string) error {
|
|
_, err := tx.ExecContext(ctx, "REPLACE INTO local_metadata (`key`, value) VALUES (?, ?)", key, value)
|
|
if err != nil {
|
|
return fmt.Errorf("set local metadata %s: %w", key, err)
|
|
}
|
|
return nil
|
|
}
|
|
|
|
// GetLocalMetadataInTx retrieves a value from the dolt-ignored local_metadata
|
|
// table within an existing transaction. Returns ("", nil) if the key does not exist.
|
|
func GetLocalMetadataInTx(ctx context.Context, tx DBTX, key string) (string, error) {
|
|
var value string
|
|
err := tx.QueryRowContext(ctx, "SELECT value FROM local_metadata WHERE `key` = ?", key).Scan(&value)
|
|
if err == sql.ErrNoRows {
|
|
return "", nil
|
|
}
|
|
if err != nil {
|
|
return "", fmt.Errorf("get local metadata %s: %w", key, err)
|
|
}
|
|
return value, nil
|
|
}
|