Codync
免费开源的 1:1 Grok Bot 与 Muse 替代方案。可在 iPhone、Mac 或 Linux 桌面上将 Claude 代码、Codex、Cursor 以及 40 多个编码代理作为持久机器人使用。支持群组聊天、线程、应用。
AI 翻译
制作者的介绍仅有上面的一句话。 更多详情请阅读仓库 README。 仓库 README ↗
正在加载完整 README。
查看完整 README ↗It is problematic to embed line-specific GitHub permalinks in documentation because changes to the target file can invalidate the permalink line references.
srcref solves this problem by using regex patterns to dynamically locate code sections, generating GitHub permalinks that remain valid even when files are modified.
Key Benefits:
val permalink = Api.srcrefUrl(
account = "pambrose",
repo = "srcref",
path = "src/main/kotlin/Main.kt",
beginRegex = "fun main",
endRegex = "embeddedServer"
)
regex values use this syntax.
Remember to protect regex characters like (), [] and {} by prefixing them with a \.
Use regex101.com to assist in creating regex values.To highlight all the lines from the first occurrence
of install(CallLogging) to 3 lines beyond the first occurrence of install(Compression) in
src/main/kotlin/Main.kt,
create a srcref URL using
these values
.
The corresponding srcref URL generates this GitHub permalink .
| Parameter | Default | Required | Description |
|---|---|---|---|
| account | Yes | GitHub account or organization name | |
| repo | Yes | Repo name | |
| branch | "master" | Yes | Branch name |
| path | Yes | File path in repo | |
| bregex | Yes | The regex used to determine the beginning match | |
| boccur | 1 | Yes | The number of matches for the beginning match |
| boffset | 0 | Yes | The number of lines above or below the beginning match |
| btopd | true | Yes | The direction to evaluate the file for the beginning match |
| eregex | No | The regex used to determine the ending match | |
| eoccur | 1 | No | The number of matches for the ending match |
| eoffset | 0 | No | The number of lines above or below the ending match |
| etopd | true | No | The direction to evaluate the file for the ending match |
Add &edit to a srcref URL to edit it.
srcref URLs can be generated programmatically with the srcrefUrl() call. An example can be seen
here
.
dependencies {
implementation("com.pambrose:srcref:2.3.1")
}
dependencies {
implementation 'com.pambrose:srcref:2.3.1'
}
<dependency>
<groupId>com.pambrose</groupId>
<artifactId>srcref</artifactId>
<version>2.3.1</version>
</dependency>
srcref uses regex patterns to dynamically locate code sections in GitHub repositories:
Reference specific code sections in:
// Match function declarations
fun\s+\w+\(
// Match class definitions
class\s+\w+
// Match import statements
import\s+[\w.]+
// Match specific method calls
\.methodName\(
// Match multi-line constructs
try\s*\{ // Begin regex
}\s*catch // End regex
// Match configuration blocks
install\([\w]+\) // Begin regex
} // End regex (with offset)
// Match between comments
//\s*START.* // Begin regex
//\s*END.* // End regex
# Clone the repository
git clone https://github.com/pambrose/srcref.git
cd srcref
# Run the dev server on port 8080
./gradlew run
# ...or build a self-contained JAR and run that
./gradlew buildFatJar
java -jar build/libs/srcref-all.jar
# Build Docker image
docker build -t srcref .
# Run with environment variables
docker run -p 8080:8080 \
-e PORT=8080 \
-e PREFIX=https://your-domain.com \
srcref
# Deploy to Heroku
heroku create your-srcref-app
git push heroku master
| Variable | Default | Description |
|---|---|---|
PORT | 8080 | HTTP port to listen on |
PREFIX | "https://www.srcref.com" | Prefix for generated URLs |
MAX_LENGTH | 5MB | Maximum allowed file size |
MAX_CACHE_SIZE | 2048 | Maximum cache size before evictions |
DEFAULT_BRANCH | "master" | Default branch name to use if branch parameter is missing |
srcrefUrl() Functionfun srcrefUrl(
account: String, // GitHub username or organization
repo: String, // Repository name
path: String, // File path in repository
beginRegex: String, // Regex to find start position
beginOccurrence: Int = 1, // Which occurrence to use (1st, 2nd, etc.)
beginOffset: Int = 0, // Lines to offset from match
beginTopDown: Boolean = true, // Search direction
endRegex: String = "", // Optional: regex to find end position
endOccurrence: Int = 1, // Which end occurrence to use
endOffset: Int = 0, // Lines to offset from end match
endTopDown: Boolean = true, // End search direction
prefix: String = "https://www.srcref.com", // Base URL
branch: String = "master", // Git branch
escapeHtml4: Boolean = false // HTML escape the output
): String
| Endpoint | Purpose | Parameters |
|---|---|---|
/edit | Main form interface | All query parameters |
/github | Generate GitHub permalink | All query parameters |
/github?edit | Edit existing srcref URL | All query parameters + edit |
/problem | Display error information | msg + original parameters |
/what | Information about srcref | None |
/cache | Cache status and statistics | None |
/version | Version and build information | None |
/ping | Health check endpoint | None |
srcref provides detailed error messages for common issues:
git checkout -b feature/amazing-feature)git commit -m 'Add amazing feature')git push origin feature/amazing-feature)# Clone repository
git clone https://github.com/pambrose/srcref.git
cd srcref
# List available make targets
make help
# Build project
./gradlew build
# Run tests
./gradlew test
# Generate coverage report (HTML at build/reports/kover/html/)
make coverage
# Per-package coverage summary (uses scripts/coverage_packages.py)
make coverage-packages
# Audit the GitHub Actions workflows and Dependabot config (uses uvx zizmor)
make zizmor
# Run the CI workflows' build steps locally: tests, docs site build, and zizmor
make ci
# Start development server
./gradlew run
# Create executable JAR
make uber
# Build Docker image
make build-docker
# Run all checks
make tests
This project is licensed under the Apache License 2.0 - see the LICENSE.txt file for details.