Skip to main content

Source repositories

A source repository is an organization git repository that Kadu clones before the skill runs, in a read-only copy. The skill reads the code as in any folder (searches, opens files) and answers from it.

Use one when the task needs to know what the code actually does: answering the team's questions about a product, checking whether the documentation matches the implementation, writing an article from what is in the repository, reviewing a business rule before explaining it to a customer. The person who asks (in the console, in Slack or through the API) does not need access to the repository: Kadu is the one reading it, with the organization's credential.

UseFor
Source repositoryreading code that changes outside Kadu, always at the newest version of the branch
Volumefiles the task itself writes and needs to find on the next execution
Input fileswhat a person attaches when running the task

In two parts​

  1. Register. Declare the repository in the sources: section of kadu.yaml, or register it through the API (POST /v1/sources), MCP (kadu_sources_create) or the CLI (kobana kadu sources create).
  2. Use. Each task that needs it declares the name in task.sources, in the SKILL.md frontmatter.

The Playbook repository only picks names. Which repository, and with which credential, is decided by Kadu when the task runs. The code never goes through the console, the API or MCP: they show only the address, the ref, the credential type and the outcome of the last access check.

How Kadu gets access​

Kadu picks the credential when the repository is registered:

CredentialWhenWhat you do
GitHub App (github_app)Kadu's GitHub App, already linked to the organization for the Playbook, is also installed on the repositoryNothing: access is checked right away
Deploy key (deploy_key)In any other case (another GitHub account, App not installed)Register the public key Kadu generated as a read-only Deploy Key on the repository and check access

With the GitHub App, each execution receives an installation token valid for one hour, read-only and only for that repository. With a deploy key, Kadu generates a key pair per repository (GitHub does not accept the same deploy key on two repositories) and stores the private key encrypted. It is never shown.

Only the App installation linked to your organization counts. Any other installation that covers the repository does not grant access: Kadu never uses another organization's credential.

Register the deploy key​

  1. Register the repository (in kadu.yaml or through the API). The API response carries deploy_key_public_key and deploy_key_settings_url; after syncing kadu.yaml, look them up with kobana kadu sources get.
  2. On GitHub, in the repository's Settings → Deploy keys → Add deploy key, paste the public key. Do not check Allow write access.
  3. Check access: POST /v1/sources/{id}/check, the kadu_sources_check tool or kobana kadu sources check. With access, access_status becomes ok and last_commit_sha shows the ref's commit.

Registering a deploy key requires being an administrator of the repository. That is what proves the organization may read it.

Declare in kadu.yaml​

sources:
- name: apps-billing # the name tasks use
repository: universokobana/kobana-billing # owner/repo on GitHub
ref: main # optional: branch or tag; default: the default branch
label: Faturamento # optional: the display name
workspace: product # optional: only this plugin's tasks read it
FieldRule
nameRequired. Lowercase letters, digits and hyphens, starting with a letter or digit, up to 63 characters. Unique in the organization.
repositoryRequired. GitHub owner/repo (the URL https://github.com/owner/repo also works). It does not change after registration.
refOptional. Branch or tag cloned. Without it, the repository's default branch.
labelOptional. Display name.
workspaceOptional. The plugin whose tasks may read the repository. Without it, any task in the organization can.

The sync follows the kadu.yaml ownership rule: it registers and updates what is declared and deletes only what it registered itself. See The kadu.yaml.

Declare in the task: block​

---
name: task-answer-app-question
description: Answers questions about the apps from the source code
task:
label: "Answer a question about the apps"
workspace: Product
activity: Questions
model: tier-3
conversational: true
sources:
- apps-billing
- apps-hub
---
RuleDetail
FormatA list of names (- apps-billing) or of { name } objects
LimitAt most 10 repositories per task
Malformed itemAn invalid name, an unknown key or a repeated name discards the whole list, with a warning. The stored value stays
Absentsources missing from the frontmatter keeps what was stored; sources: [] clears it
Repository that does not existSync warning (repositório "…" não existe); the execution fails when it starts

The whole list is dropped over one bad item on purpose: cloning only some of the repositories would make the skill answer without the code it expects, and the error would show up far from the cause.

In the skill: the folders and the variables​

VariableContent
KADU_SOURCES_DIRThe folder with all of the execution's repositories (.execution-files/sources/)
KADU_SOURCE_<NAME>Each repository's folder. The name is uppercased, with - replaced by _: apps-billing → KADU_SOURCE_APPS_BILLING

$KADU_SOURCES_DIR/sources.json holds, for each repository, the name, the owner/repo, the ref and the cloned commit. Cite the commit in the answer when it depends on a specific version of the code.

source /tmp/agent_state.sh
mark_body_started

jq -r '.[] | "\(.name): \(.repository)@\(.commit[0:12])"' "$KADU_SOURCES_DIR/sources.json"

# Where is the subscription plan calculated?
grep -rn "calculatePlan" "$KADU_SOURCE_APPS_BILLING/lib" | head

The clone is shallow (only the ref's latest commit), has no .git and is read-only: there is no history to query (the commit is in sources.json), the skill cannot change the files, and nothing goes back to GitHub. To propose a change to a repository, the skill clones it on its own with a write token in required_secrets and opens a pull request.

What happens in the execution​

  1. Clone. Before the skill starts, Kadu checks each repository's organization and workspace, generates the credential and clones the ref. The execution timeline shows each repository with the cloned commit.
  2. Deliver. The copy goes to .execution-files/sources/<name>/, without write permission. The agent receives only the paths, never the token or the deploy key.
  3. Discard. At the end of the execution, the copy is deleted. Each execution clones again, so it always sees the newest version of the ref.

A refused repository (does not exist, belongs to another workspace, no access) fails the execution before the skill runs: answering without part of the code would be worse than failing.

Conversational tasks​

In a conversational task, each round is an execution and clones the repositories again. If someone pushed a commit between two rounds, the new round reads the new code. The clone is not part of the conversation's saved session.

Limits​

LimitValue
Repositories per task10
Combined size of the clones2 GiB
Time to clone each repository10 minutes
Clone depth1 commit (the ref's latest)

Cloning counts toward the execution's 60 minutes.

When something goes wrong​

What happensEffect
Repository that does not exist (source_not_found)The execution fails when it starts, with "Repositórios de código indisponíveis"
Repository restricted to another workspace (source_not_allowed)Same
GitHub App unlinked from the organization (credential_unavailable)Same. Register the repository again under another name to receive a deploy key
Deploy key not registered or removed from GitHubThe execution fails while cloning: "confira a deploy key"
Ref that does not existThe execution fails while cloning. The access check shows ref_not_found
Clones above 2 GiBThe execution fails before the skill runs

Use the access check (kobana kadu sources check) to find the problem before an execution: it lists the ref on GitHub with the credential, without cloning, and records access_status and last_check_error (access_denied, ref_not_found, credential_unavailable or unreachable).

Security​

  • Whoever runs the task reads the code through the answer. The task may quote parts of the repository in the result, in Slack and in the output files. Give access to the task (through roles and Slack channels) only to people who may see that code.
  • The code is input to the model. Comments and files in the repository may carry instructions for the model (prompt injection). Treat what it reads as data.
  • Read-only, always. The deploy key is registered without write access and the GitHub App token only has contents: read. To write, use your own token in required_secrets, with the minimum scope.
  • GitHub is verified. With a deploy key, Kadu only accepts the host keys GitHub publishes: a man in the middle cannot hand other code to the run.
  • Restrict with workspace. A repository that only one area uses should not be visible to the other areas' tasks.

Through the API, MCP and the CLI​

/v1/sources registers, lists, updates and deletes repositories, and POST /v1/sources/{id}/check checks access (reference). In MCP, the kadu_sources_* tools (Configuration). In the CLI, kobana kadu sources … (Source repositories).