@fitlab-ai/agent-infra 0.12.1 → 0.12.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -2
- package/README.zh-CN.md +0 -2
- package/dist/bin/internal-cli.js +2 -17
- package/dist/lib/agent-clients/adapter.js +0 -13
- package/dist/lib/agent-clients/adapters/antigravity-cli.js +0 -5
- package/dist/lib/agent-clients/adapters/claude-code-credentials.js +0 -17
- package/dist/lib/agent-clients/adapters/claude-code.js +0 -9
- package/dist/lib/agent-clients/adapters/codex.js +0 -52
- package/dist/lib/agent-clients/adapters/opencode.js +0 -5
- package/dist/lib/agent-clients/adapters/traecli.js +0 -5
- package/dist/lib/agent-clients/config.js +19 -54
- package/dist/lib/agent-clients/registry.js +1 -12
- package/dist/lib/agent-clients/schema.js +0 -18
- package/dist/lib/agent-clients/tokens.js +1 -2
- package/dist/lib/agent-clients/types.js +0 -1
- package/dist/lib/decide.js +2 -0
- package/dist/lib/git/worktree-identity.js +1 -9
- package/dist/lib/internal/agent-client.js +2 -62
- package/dist/lib/internal/cli-route-inventory.js +1 -5
- package/dist/lib/internal/manual-validation.js +18 -10
- package/dist/lib/internal/task-create.js +1 -1
- package/dist/lib/internal/task-event.js +1 -8
- package/dist/lib/internal/task-finalization.js +0 -1
- package/dist/lib/internal/task-lifecycle.js +2 -2
- package/dist/lib/internal/task-operation-registry.js +4 -20
- package/dist/lib/internal/task-review.js +4 -4
- package/dist/lib/platform/comment-safety.js +1 -7
- package/dist/lib/platform/in-label-sync.js +1 -14
- package/dist/lib/platform/issue-comments.js +1 -16
- package/dist/lib/platform/issues.js +1 -1
- package/dist/lib/platform/operation-coordinator.js +4 -2
- package/dist/lib/platform/pr-change-report.js +1 -4
- package/dist/lib/platform/pr-checks.js +2 -8
- package/dist/lib/platform/provider-validation.js +0 -20
- package/dist/lib/platform/pull-requests.js +73 -84
- package/dist/lib/platform/releases.js +1 -43
- package/dist/lib/platform/verification-required.js +0 -2
- package/dist/lib/platform/verification-sync.js +1 -79
- package/dist/lib/process-data/normalize.js +1 -185
- package/dist/lib/process-data/privacy.js +1 -16
- package/dist/lib/process-data/sources.js +2 -279
- package/dist/lib/render.js +0 -12
- package/dist/lib/run/index.js +15 -10
- package/dist/lib/run/skills.js +0 -3
- package/dist/lib/sandbox/commands/create.js +40 -53
- package/dist/lib/sandbox/commands/list-running.js +0 -18
- package/dist/lib/sandbox/commands/start.js +7 -8
- package/dist/lib/sandbox/constants.js +0 -6
- package/dist/lib/sandbox/control/client.js +0 -1
- package/dist/lib/sandbox/control/container-identity.js +1 -16
- package/dist/lib/sandbox/control/executor.js +0 -4
- package/dist/lib/sandbox/control/identity-sentinel.js +0 -7
- package/dist/lib/sandbox/control/lifecycle.js +21 -37
- package/dist/lib/sandbox/control/native-file-lock.js +0 -3
- package/dist/lib/sandbox/control/server.js +18 -38
- package/dist/lib/sandbox/control/state.js +1 -9
- package/dist/lib/sandbox/dockerfile.js +0 -6
- package/dist/lib/sandbox/engine.js +0 -14
- package/dist/lib/sandbox/engines/docker-exact-discovery.js +1 -4
- package/dist/lib/sandbox/engines/wsl2-paths.js +0 -3
- package/dist/lib/sandbox/recovery.js +24 -26
- package/dist/lib/sandbox/removal.js +11 -519
- package/dist/lib/sandbox/task-resolver.js +0 -41
- package/dist/lib/sandbox/tools.js +1 -4
- package/dist/lib/sandbox/workspace-view.js +1 -2
- package/dist/lib/server/display.js +0 -6
- package/dist/lib/task/activity-intent.js +45 -40
- package/dist/lib/task/activity-log.js +9 -16
- package/dist/lib/task/artifact-command.js +1 -1
- package/dist/lib/task/artifact-lifecycle.js +61 -63
- package/dist/lib/task/artifact-name.js +0 -6
- package/dist/lib/task/artifact-operations.js +3 -3
- package/dist/lib/task/capabilities.js +4 -5
- package/dist/lib/task/commands/log.js +0 -6
- package/dist/lib/task/commands/status.js +17 -60
- package/dist/lib/task/commit-operation.js +28 -39
- package/dist/lib/task/completion-facts.js +56 -43
- package/dist/lib/task/control-authority.js +23 -256
- package/dist/lib/task/control-recovery.js +3 -5
- package/dist/lib/task/create.js +2 -4
- package/dist/lib/task/decision-intents.js +8 -9
- package/dist/lib/task/delivery-target.js +1 -40
- package/dist/lib/task/events.js +84 -107
- package/dist/lib/task/finalization.js +44 -8
- package/dist/lib/task/ledger-intents.js +1 -1
- package/dist/lib/task/lifecycle-execution.js +38 -33
- package/dist/lib/task/lifecycle.js +49 -41
- package/dist/lib/task/local-artifact-finalization.js +1 -4
- package/dist/lib/task/manual-validation-evidence.js +1 -37
- package/dist/lib/task/platform-operation-recovery.js +67 -24
- package/dist/lib/task/pr-delivery-fact.js +2 -5
- package/dist/lib/task/qualification-confirmation.js +5 -7
- package/dist/lib/task/resolve-ref.js +1 -25
- package/dist/lib/task/review-command.js +2 -2
- package/dist/lib/task/review-finalization.js +1 -21
- package/dist/lib/task/review-fingerprint.js +0 -4
- package/dist/lib/task/secure-fs.js +0 -56
- package/dist/lib/task/short-id.js +1 -39
- package/dist/lib/task/skill-scope.js +0 -1
- package/dist/lib/task/verification-engine.js +58 -282
- package/dist/lib/task/verification.js +6 -3
- package/dist/lib/task/write.js +11 -1
- package/lib/agent-clients/adapter.ts +0 -76
- package/lib/agent-clients/adapters/antigravity-cli.ts +0 -5
- package/lib/agent-clients/adapters/claude-code-credentials.ts +0 -19
- package/lib/agent-clients/adapters/claude-code.ts +0 -9
- package/lib/agent-clients/adapters/codex.ts +0 -56
- package/lib/agent-clients/adapters/opencode.ts +0 -5
- package/lib/agent-clients/adapters/traecli.ts +0 -5
- package/lib/agent-clients/config.ts +20 -61
- package/lib/agent-clients/registry.ts +1 -34
- package/lib/agent-clients/schema.ts +0 -18
- package/lib/agent-clients/tokens.ts +1 -2
- package/lib/agent-clients/types.ts +0 -15
- package/lib/decide.ts +1 -0
- package/lib/git/worktree-identity.ts +0 -10
- package/lib/internal/agent-client.ts +2 -70
- package/lib/internal/cli-route-inventory.ts +1 -4
- package/lib/internal/manual-validation.ts +16 -9
- package/lib/internal/task-create.ts +0 -1
- package/lib/internal/task-event.ts +1 -5
- package/lib/internal/task-finalization.ts +0 -1
- package/lib/internal/task-lifecycle.ts +3 -5
- package/lib/internal/task-operation-registry.ts +3 -19
- package/lib/internal/task-review.ts +4 -4
- package/lib/platform/comment-safety.ts +0 -10
- package/lib/platform/github-provider.ts +0 -2
- package/lib/platform/in-label-sync.ts +0 -16
- package/lib/platform/issue-comments.ts +0 -21
- package/lib/platform/issues.ts +0 -2
- package/lib/platform/operation-coordinator.ts +4 -2
- package/lib/platform/pr-change-report.ts +0 -5
- package/lib/platform/pr-checks.ts +1 -10
- package/lib/platform/pr-review.ts +1 -1
- package/lib/platform/provider-bridge.ts +0 -1
- package/lib/platform/provider-loader.ts +1 -5
- package/lib/platform/provider-validation.ts +1 -49
- package/lib/platform/pull-requests.ts +64 -99
- package/lib/platform/releases.ts +1 -40
- package/lib/platform/verification-required.ts +0 -2
- package/lib/platform/verification-sync.ts +0 -94
- package/lib/process-data/normalize.ts +1 -186
- package/lib/process-data/privacy.ts +2 -19
- package/lib/process-data/sources.ts +3 -283
- package/lib/render.ts +0 -15
- package/lib/run/index.ts +13 -7
- package/lib/run/skills.ts +0 -4
- package/lib/sandbox/commands/create.ts +37 -74
- package/lib/sandbox/commands/list-running.ts +0 -19
- package/lib/sandbox/commands/start.ts +7 -10
- package/lib/sandbox/constants.ts +0 -8
- package/lib/sandbox/control/client.ts +0 -1
- package/lib/sandbox/control/container-identity.ts +1 -16
- package/lib/sandbox/control/executor.ts +1 -5
- package/lib/sandbox/control/identity-sentinel.ts +0 -8
- package/lib/sandbox/control/lifecycle.ts +18 -51
- package/lib/sandbox/control/native-file-lock.ts +0 -8
- package/lib/sandbox/control/protocol.ts +0 -2
- package/lib/sandbox/control/server.ts +13 -39
- package/lib/sandbox/control/state.ts +1 -10
- package/lib/sandbox/dockerfile.ts +0 -11
- package/lib/sandbox/engine.ts +0 -17
- package/lib/sandbox/engines/docker-exact-discovery.ts +1 -5
- package/lib/sandbox/engines/wsl2-paths.ts +0 -4
- package/lib/sandbox/recovery.ts +24 -26
- package/lib/sandbox/removal.ts +11 -696
- package/lib/sandbox/shell.ts +1 -1
- package/lib/sandbox/task-resolver.ts +0 -48
- package/lib/sandbox/tools.ts +1 -5
- package/lib/sandbox/workspace-view.ts +2 -4
- package/lib/server/display.ts +0 -14
- package/lib/server/process-control.ts +1 -1
- package/lib/task/activity-intent.ts +36 -44
- package/lib/task/activity-log.ts +9 -22
- package/lib/task/artifact-command.ts +1 -1
- package/lib/task/artifact-lifecycle.ts +58 -67
- package/lib/task/artifact-name.ts +0 -7
- package/lib/task/artifact-operations.ts +3 -3
- package/lib/task/capabilities.ts +5 -6
- package/lib/task/commands/log.ts +0 -7
- package/lib/task/commands/status.ts +14 -79
- package/lib/task/commit-operation.ts +29 -51
- package/lib/task/completion-facts.ts +45 -42
- package/lib/task/control-authority.ts +27 -317
- package/lib/task/control-recovery.ts +2 -5
- package/lib/task/create.ts +2 -5
- package/lib/task/decision-intents.ts +5 -5
- package/lib/task/delivery-target.ts +0 -40
- package/lib/task/events.ts +89 -123
- package/lib/task/finalization.ts +41 -9
- package/lib/task/ledger-intents.ts +1 -1
- package/lib/task/lifecycle-execution.ts +37 -89
- package/lib/task/lifecycle.ts +48 -44
- package/lib/task/local-artifact-finalization.ts +0 -7
- package/lib/task/manual-validation-evidence.ts +1 -47
- package/lib/task/platform-operation-recovery.ts +50 -26
- package/lib/task/pr-delivery-fact.ts +2 -11
- package/lib/task/qualification-confirmation.ts +6 -6
- package/lib/task/resolve-ref.ts +0 -23
- package/lib/task/review-command.ts +2 -2
- package/lib/task/review-finalization.ts +1 -27
- package/lib/task/review-fingerprint.ts +0 -8
- package/lib/task/secure-fs.ts +0 -42
- package/lib/task/short-id.ts +0 -43
- package/lib/task/skill-scope.ts +0 -1
- package/lib/task/verification-engine.ts +56 -287
- package/lib/task/verification.ts +5 -5
- package/lib/task/write.ts +12 -1
- package/package.json +2 -2
- package/templates/.agents/README.en.md +1 -3
- package/templates/.agents/README.zh-CN.md +0 -2
- package/templates/.agents/rules/README.en.md +0 -1
- package/templates/.agents/rules/README.zh-CN.md +0 -1
- package/templates/.agents/rules/commit-and-pr.en.md +1 -1
- package/templates/.agents/rules/commit-and-pr.zh-CN.md +1 -1
- package/templates/.agents/rules/no-mid-flow-questions.en.md +0 -10
- package/templates/.agents/rules/no-mid-flow-questions.zh-CN.md +0 -10
- package/templates/.agents/rules/pr-sync.en.md +1 -1
- package/templates/.agents/rules/pr-sync.zh-CN.md +1 -1
- package/templates/.agents/rules/task-management.en.md +3 -3
- package/templates/.agents/rules/task-management.zh-CN.md +3 -3
- package/templates/.agents/skills/analyze-task/SKILL.en.md +3 -3
- package/templates/.agents/skills/analyze-task/SKILL.zh-CN.md +3 -3
- package/templates/.agents/skills/cancel-task/SKILL.en.md +2 -2
- package/templates/.agents/skills/cancel-task/SKILL.zh-CN.md +2 -2
- package/templates/.agents/skills/code-task/SKILL.en.md +2 -2
- package/templates/.agents/skills/code-task/SKILL.zh-CN.md +4 -4
- package/templates/.agents/skills/commit/SKILL.en.md +2 -2
- package/templates/.agents/skills/commit/SKILL.zh-CN.md +2 -2
- package/templates/.agents/skills/commit/reference/commit-orchestration.en.md +6 -6
- package/templates/.agents/skills/commit/reference/commit-orchestration.zh-CN.md +6 -6
- package/templates/.agents/skills/plan-task/SKILL.en.md +2 -2
- package/templates/.agents/skills/plan-task/SKILL.zh-CN.md +2 -2
- package/templates/.agents/skills/review-analysis/SKILL.en.md +3 -3
- package/templates/.agents/skills/review-analysis/SKILL.zh-CN.md +3 -3
- package/templates/.agents/skills/review-code/SKILL.en.md +5 -5
- package/templates/.agents/skills/review-code/SKILL.zh-CN.md +5 -5
- package/templates/.agents/skills/review-plan/SKILL.en.md +3 -3
- package/templates/.agents/skills/review-plan/SKILL.zh-CN.md +3 -3
- package/templates/.agents/skills/review-pr/SKILL.en.md +4 -4
- package/templates/.agents/skills/review-pr/SKILL.zh-CN.md +4 -4
- package/templates/.agents/skills/run-manual-validation/SKILL.en.md +1 -1
- package/templates/.agents/skills/run-manual-validation/SKILL.zh-CN.md +1 -1
- package/templates/.agents/skills/update-agent-infra/scripts/sync-templates.js +3 -75
- package/templates/.agents/templates/task.en.md +1 -0
- package/templates/.agents/templates/task.zh-CN.md +1 -0
- package/templates/.claude/settings.json +0 -24
- package/templates/.codex/hooks.json +0 -50
- package/dist/lib/agent-clients/adapters/codex-lifecycle/app-server.js +0 -582
- package/dist/lib/agent-clients/adapters/codex-lifecycle/binding.js +0 -114
- package/dist/lib/agent-clients/adapters/codex-lifecycle/build-identity.js +0 -237
- package/dist/lib/agent-clients/adapters/codex-lifecycle/cli.js +0 -443
- package/dist/lib/agent-clients/adapters/codex-lifecycle/evidence.js +0 -236
- package/dist/lib/agent-clients/adapters/codex-lifecycle/recovery.js +0 -292
- package/dist/lib/agent-clients/adapters/codex-lifecycle/store.js +0 -267
- package/dist/lib/agent-clients/adapters/codex-orchestration.js +0 -466
- package/dist/lib/internal/task-orchestration.js +0 -71
- package/dist/lib/platform/verification.js +0 -6
- package/dist/lib/run/prompt.js +0 -2
- package/dist/lib/sandbox/engines/authority.js +0 -289
- package/dist/lib/task/delegation-receipts.js +0 -410
- package/dist/lib/task/orchestration.js +0 -1233
- package/dist/lib/task/verification-checks.js +0 -9
- package/dist/lib/task/workspace-snapshot.js +0 -121
- package/dist/lifecycle-build-manifest.json +0 -6
- package/lib/agent-clients/adapters/codex-lifecycle/app-server.ts +0 -688
- package/lib/agent-clients/adapters/codex-lifecycle/binding.ts +0 -147
- package/lib/agent-clients/adapters/codex-lifecycle/build-identity.ts +0 -349
- package/lib/agent-clients/adapters/codex-lifecycle/cli.ts +0 -506
- package/lib/agent-clients/adapters/codex-lifecycle/evidence.ts +0 -385
- package/lib/agent-clients/adapters/codex-lifecycle/manifest-files.json +0 -41
- package/lib/agent-clients/adapters/codex-lifecycle/recovery.ts +0 -418
- package/lib/agent-clients/adapters/codex-lifecycle/store.ts +0 -354
- package/lib/agent-clients/adapters/codex-orchestration.ts +0 -630
- package/lib/internal/task-orchestration.ts +0 -74
- package/lib/platform/verification.ts +0 -11
- package/lib/run/prompt.ts +0 -1
- package/lib/sandbox/engines/authority.ts +0 -365
- package/lib/task/delegation-receipts.ts +0 -547
- package/lib/task/orchestration.ts +0 -1651
- package/lib/task/verification-checks.ts +0 -10
- package/lib/task/workspace-snapshot.ts +0 -144
- package/templates/.agents/hooks/lifecycle-delegation.js +0 -140
- package/templates/.agents/rules/lifecycle-orchestration.en.md +0 -44
- package/templates/.agents/rules/lifecycle-orchestration.zh-CN.md +0 -44
- package/templates/.agents/skills/run-task/SKILL.en.md +0 -29
- package/templates/.agents/skills/run-task/SKILL.zh-CN.md +0 -29
- package/templates/.agents/skills/run-task/config/verify.en.json +0 -10
- package/templates/.agents/skills/run-task/config/verify.zh-CN.json +0 -10
- package/templates/.agents/skills/run-task/reference/host-validation.en.md +0 -24
- package/templates/.agents/skills/run-task/reference/host-validation.zh-CN.md +0 -24
- package/templates/.claude/agents/agent-infra-lifecycle-executor.en.md +0 -6
- package/templates/.claude/agents/agent-infra-lifecycle-executor.zh-CN.md +0 -6
- package/templates/.claude/agents/agent-infra-lifecycle-reviewer.en.md +0 -6
- package/templates/.claude/agents/agent-infra-lifecycle-reviewer.zh-CN.md +0 -6
- package/templates/.claude/commands/run-task.en.md +0 -8
- package/templates/.claude/commands/run-task.zh-CN.md +0 -8
- package/templates/.codex/agents/agent-infra-lifecycle-executor.en.toml +0 -3
- package/templates/.codex/agents/agent-infra-lifecycle-executor.zh-CN.toml +0 -3
- package/templates/.codex/agents/agent-infra-lifecycle-reviewer.en.toml +0 -3
- package/templates/.codex/agents/agent-infra-lifecycle-reviewer.zh-CN.toml +0 -3
- package/templates/.opencode/commands/run-task.en.md +0 -11
- package/templates/.opencode/commands/run-task.zh-CN.md +0 -11
|
@@ -1,192 +1,8 @@
|
|
|
1
1
|
import { sha256 } from './store.js';
|
|
2
|
-
import { normalizeAgentToken } from '../agent-clients/tokens.js';
|
|
3
2
|
const TASK_ID_RE = /TASK-\d{8}-\d{6}/;
|
|
4
|
-
const ACTIVITY_RE = /^- (\d{4}-\d{2}-\d{2} [^ ]+) — \*\*(.+?)\*\* by ([^ ]+) — (.+)$/gm;
|
|
5
|
-
const LEDGER_RE = /^\|\s*((?:AN|PL|CD)-\d+)\s*\|\s*(analysis|plan|code)\s*\|\s*([^|]+?)\s*\|\s*([^|]+?)\s*\|\s*([^|]+?)\s*\|\s*([^|]+?)\s*\|$/gm;
|
|
6
|
-
const RULING_RE = /^###\s+(HDR-\d+)\s*$([\s\S]*?)(?=^###\s+|^##\s+|(?![\s\S]))/gm;
|
|
7
|
-
const CONFLICT_STATUSES = new Set(['open', 'accepted', 'adjusted', 'refuted', 'cannot-judge', 'needs-human-decision']);
|
|
8
3
|
function recordId(kind, identity, suffix = '') {
|
|
9
4
|
return `${kind}:${sha256(`${identity}\0${suffix}`).slice(0, 24)}`;
|
|
10
5
|
}
|
|
11
|
-
function canonicalActor(raw) {
|
|
12
|
-
const lowered = raw.toLowerCase();
|
|
13
|
-
return normalizeAgentToken(lowered);
|
|
14
|
-
}
|
|
15
|
-
function nextOccurrence(occurrences, identity) {
|
|
16
|
-
const occurrence = (occurrences.get(identity) ?? 0) + 1;
|
|
17
|
-
occurrences.set(identity, occurrence);
|
|
18
|
-
return occurrence === 1 ? '' : `occurrence=${occurrence}`;
|
|
19
|
-
}
|
|
20
|
-
function normalizePlatformPage(object) {
|
|
21
|
-
if (!object.content)
|
|
22
|
-
return [];
|
|
23
|
-
try {
|
|
24
|
-
const page = JSON.parse(object.content);
|
|
25
|
-
if (!Array.isArray(page))
|
|
26
|
-
return [];
|
|
27
|
-
return page.map((entry, index) => {
|
|
28
|
-
const value = entry;
|
|
29
|
-
const identity = String(value.id ?? value.node_id ?? value.sha ?? value.number ?? `${object.sourceIdentity}:${index}`);
|
|
30
|
-
const platformIdentity = /\/issues\?/.test(object.sourceIdentity) && typeof value.number === 'number'
|
|
31
|
-
? `issue:${value.number}`
|
|
32
|
-
: /\/pulls\?/.test(object.sourceIdentity) && typeof value.number === 'number'
|
|
33
|
-
? `pr:${value.number}`
|
|
34
|
-
: /\/issues\/\d+\/comments/.test(object.sourceIdentity)
|
|
35
|
-
? `issue-comment:${identity}`
|
|
36
|
-
: /\/pulls\/\d+\/reviews/.test(object.sourceIdentity)
|
|
37
|
-
? `review:${identity}`
|
|
38
|
-
: /\/pulls\/\d+\/commits/.test(object.sourceIdentity)
|
|
39
|
-
? `commit:${identity}`
|
|
40
|
-
: `platform:${identity}`;
|
|
41
|
-
const binding = typeof value.body === 'string' ? value.body.match(TASK_ID_RE)?.[0] : undefined;
|
|
42
|
-
return {
|
|
43
|
-
recordId: recordId('platform-resource', object.sourceIdentity, identity),
|
|
44
|
-
kind: 'platform-resource',
|
|
45
|
-
sourceIdentity: platformIdentity,
|
|
46
|
-
sourceSha256: object.sha256,
|
|
47
|
-
...(binding ? { binding } : {}),
|
|
48
|
-
data: entry
|
|
49
|
-
};
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
catch {
|
|
53
|
-
return [];
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
function normalizeObjects(objects) {
|
|
57
|
-
const records = [];
|
|
58
|
-
for (const object of objects) {
|
|
59
|
-
if (object.disposition?.state && object.disposition.state !== 'included') {
|
|
60
|
-
records.push({
|
|
61
|
-
recordId: recordId('missing', object.sourceIdentity),
|
|
62
|
-
kind: 'missing',
|
|
63
|
-
sourceIdentity: object.sourceIdentity,
|
|
64
|
-
sourceSha256: object.sha256,
|
|
65
|
-
data: object.disposition.state === 'excluded-sensitive'
|
|
66
|
-
? { reason: 'privacy-excluded', ruleId: object.disposition.ruleId }
|
|
67
|
-
: { reason: object.disposition.reason }
|
|
68
|
-
});
|
|
69
|
-
continue;
|
|
70
|
-
}
|
|
71
|
-
if (object.sourceKind === 'github-rest') {
|
|
72
|
-
records.push(...normalizePlatformPage(object));
|
|
73
|
-
continue;
|
|
74
|
-
}
|
|
75
|
-
if (object.sourceKind === 'operational-report') {
|
|
76
|
-
records.push({
|
|
77
|
-
recordId: recordId('operational-report', object.sourceIdentity),
|
|
78
|
-
kind: 'operational-report',
|
|
79
|
-
sourceIdentity: object.sourceIdentity,
|
|
80
|
-
sourceSha256: object.sha256
|
|
81
|
-
});
|
|
82
|
-
continue;
|
|
83
|
-
}
|
|
84
|
-
if (object.sourceKind === 'structured-telemetry') {
|
|
85
|
-
let data = { availability: 'unknown' };
|
|
86
|
-
try {
|
|
87
|
-
data = JSON.parse(object.content ?? '{}');
|
|
88
|
-
}
|
|
89
|
-
catch {
|
|
90
|
-
data = { availability: 'unavailable', reason: 'invalid receipt JSON' };
|
|
91
|
-
}
|
|
92
|
-
records.push({
|
|
93
|
-
recordId: recordId('telemetry', object.sourceIdentity),
|
|
94
|
-
kind: 'telemetry',
|
|
95
|
-
sourceIdentity: object.sourceIdentity,
|
|
96
|
-
sourceSha256: object.sha256,
|
|
97
|
-
data
|
|
98
|
-
});
|
|
99
|
-
continue;
|
|
100
|
-
}
|
|
101
|
-
const taskId = object.sourceIdentity.match(TASK_ID_RE)?.[0];
|
|
102
|
-
if (/\/task\.md$/.test(object.sourceIdentity) && taskId) {
|
|
103
|
-
const activityOccurrences = new Map();
|
|
104
|
-
const findingOccurrences = new Map();
|
|
105
|
-
const issueNumber = object.content?.match(/^issue_number:\s*(\d+)$/m)?.[1];
|
|
106
|
-
const agentInfraVersion = object.content?.match(/^agent_infra_version:\s*(\S+)$/m)?.[1];
|
|
107
|
-
records.push({
|
|
108
|
-
recordId: recordId('task', taskId),
|
|
109
|
-
kind: 'task',
|
|
110
|
-
sourceIdentity: taskId,
|
|
111
|
-
sourceSha256: object.sha256,
|
|
112
|
-
...(issueNumber ? { binding: `issue:${issueNumber}` } : {}),
|
|
113
|
-
data: {
|
|
114
|
-
agentInfraVersion: agentInfraVersion
|
|
115
|
-
? { state: 'known', value: agentInfraVersion }
|
|
116
|
-
: { state: 'unknown', reason: 'legacy-task-missing-agent-infra-version' }
|
|
117
|
-
}
|
|
118
|
-
});
|
|
119
|
-
for (const match of object.content?.matchAll(ACTIVITY_RE) ?? []) {
|
|
120
|
-
const rawActor = match[3];
|
|
121
|
-
const identity = `${match[1]}:${match[2]}`;
|
|
122
|
-
const occurrence = nextOccurrence(activityOccurrences, identity);
|
|
123
|
-
records.push({
|
|
124
|
-
recordId: recordId('lifecycle-event', taskId, occurrence ? `${identity}\0${occurrence}` : identity),
|
|
125
|
-
kind: 'lifecycle-event',
|
|
126
|
-
sourceIdentity: `${taskId}#activity=${match[1]}`,
|
|
127
|
-
sourceSha256: object.sha256,
|
|
128
|
-
data: {
|
|
129
|
-
timestamp: match[1],
|
|
130
|
-
action: match[2],
|
|
131
|
-
actorRaw: rawActor,
|
|
132
|
-
actorCanonical: canonicalActor(rawActor),
|
|
133
|
-
note: match[4]
|
|
134
|
-
}
|
|
135
|
-
});
|
|
136
|
-
}
|
|
137
|
-
for (const match of object.content?.matchAll(LEDGER_RE) ?? []) {
|
|
138
|
-
const findingId = match[1].trim();
|
|
139
|
-
const stage = match[2].trim();
|
|
140
|
-
const round = match[3].trim();
|
|
141
|
-
const severity = match[4].trim();
|
|
142
|
-
const status = match[5].trim();
|
|
143
|
-
const evidence = match[6].trim();
|
|
144
|
-
const identity = `${taskId}#finding=${findingId}`;
|
|
145
|
-
const occurrence = nextOccurrence(findingOccurrences, identity);
|
|
146
|
-
const data = { findingId, stage, round, severity, status, evidence };
|
|
147
|
-
records.push({
|
|
148
|
-
recordId: recordId('review-finding', identity, occurrence),
|
|
149
|
-
kind: 'review-finding',
|
|
150
|
-
sourceIdentity: identity,
|
|
151
|
-
sourceSha256: object.sha256,
|
|
152
|
-
binding: taskId,
|
|
153
|
-
data
|
|
154
|
-
});
|
|
155
|
-
if (status && CONFLICT_STATUSES.has(status)) {
|
|
156
|
-
records.push({
|
|
157
|
-
recordId: recordId('conflict', identity, occurrence),
|
|
158
|
-
kind: 'conflict',
|
|
159
|
-
sourceIdentity: `${identity}#status=${status}`,
|
|
160
|
-
sourceSha256: object.sha256,
|
|
161
|
-
binding: taskId,
|
|
162
|
-
data
|
|
163
|
-
});
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
for (const match of object.content?.matchAll(RULING_RE) ?? []) {
|
|
167
|
-
const rulingId = match[1];
|
|
168
|
-
const identity = `${taskId}#ruling=${rulingId}`;
|
|
169
|
-
records.push({
|
|
170
|
-
recordId: recordId('human-ruling', identity),
|
|
171
|
-
kind: 'human-ruling',
|
|
172
|
-
sourceIdentity: identity,
|
|
173
|
-
sourceSha256: object.sha256,
|
|
174
|
-
binding: taskId,
|
|
175
|
-
data: { rulingId, evidence: match[2].trim() }
|
|
176
|
-
});
|
|
177
|
-
}
|
|
178
|
-
continue;
|
|
179
|
-
}
|
|
180
|
-
records.push({
|
|
181
|
-
recordId: recordId('artifact', object.sourceIdentity),
|
|
182
|
-
kind: 'artifact',
|
|
183
|
-
sourceIdentity: object.sourceIdentity,
|
|
184
|
-
sourceSha256: object.sha256,
|
|
185
|
-
...(taskId ? { binding: taskId } : {})
|
|
186
|
-
});
|
|
187
|
-
}
|
|
188
|
-
return records.sort((left, right) => left.recordId.localeCompare(right.recordId));
|
|
189
|
-
}
|
|
190
6
|
function normalizeResources(objects) {
|
|
191
7
|
const records = [];
|
|
192
8
|
for (const object of objects) {
|
|
@@ -220,5 +36,5 @@ function normalizeResources(objects) {
|
|
|
220
36
|
}
|
|
221
37
|
return records.sort((left, right) => left.recordId.localeCompare(right.recordId));
|
|
222
38
|
}
|
|
223
|
-
export {
|
|
39
|
+
export { normalizeResources };
|
|
224
40
|
//# sourceMappingURL=normalize.js.map
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { sha256 } from './store.js';
|
|
2
1
|
const RULES = [
|
|
3
2
|
{ id: 'private-key', pattern: /-----BEGIN (?:RSA |EC |OPENSSH )?PRIVATE KEY-----/ },
|
|
4
3
|
{ id: 'github-token', pattern: /\b(?:gh[opusr]_[A-Za-z0-9_]{20,}|github_pat_[A-Za-z0-9_]{20,})\b/ },
|
|
@@ -15,19 +14,5 @@ function inspectPrivacy(content) {
|
|
|
15
14
|
}
|
|
16
15
|
return { state: 'included' };
|
|
17
16
|
}
|
|
18
|
-
|
|
19
|
-
const bytes = Buffer.byteLength(content);
|
|
20
|
-
const digest = sha256(Buffer.from(content, 'utf8'));
|
|
21
|
-
const disposition = inspectPrivacy(content);
|
|
22
|
-
return disposition.state === 'included'
|
|
23
|
-
? { sourceKind, sourceIdentity, sha256: digest, bytes, content, disposition }
|
|
24
|
-
: { sourceKind, sourceIdentity, sha256: digest, bytes, disposition };
|
|
25
|
-
}
|
|
26
|
-
function redactExcerpt(content, maxBytes = 4096) {
|
|
27
|
-
if (inspectPrivacy(content).state !== 'included')
|
|
28
|
-
return null;
|
|
29
|
-
const buffer = Buffer.from(content, 'utf8');
|
|
30
|
-
return buffer.subarray(0, maxBytes).toString('utf8').replace(/\b(token|password|secret)=\S+/gi, '$1=[REDACTED]');
|
|
31
|
-
}
|
|
32
|
-
export { captureText, inspectPrivacy, redactExcerpt };
|
|
17
|
+
export { inspectPrivacy };
|
|
33
18
|
//# sourceMappingURL=privacy.js.map
|
|
@@ -1,222 +1,6 @@
|
|
|
1
|
-
import fs from 'node:fs';
|
|
2
|
-
import path from 'node:path';
|
|
3
1
|
import { createGitHubClient } from '../platform/github-client.js';
|
|
4
|
-
import {
|
|
5
|
-
import { resolveProjectTaskWorkspaceRoot } from '../task/workspace-root.js';
|
|
6
|
-
import { captureText, inspectPrivacy, redactExcerpt } from './privacy.js';
|
|
2
|
+
import { inspectPrivacy } from './privacy.js';
|
|
7
3
|
import { canonicalJsonBytes, sha256 } from './store.js';
|
|
8
|
-
function endpointForPage(endpoint, page, perPage) {
|
|
9
|
-
const parsed = new URL(endpoint, 'https://api.github.invalid/');
|
|
10
|
-
if (parsed.searchParams.has('page') || parsed.searchParams.has('per_page')) {
|
|
11
|
-
throw new Error('endpoint must not predefine page or per_page');
|
|
12
|
-
}
|
|
13
|
-
parsed.searchParams.set('per_page', String(perPage));
|
|
14
|
-
parsed.searchParams.set('page', String(page));
|
|
15
|
-
return `${parsed.pathname.replace(/^\//, '')}${parsed.search}`;
|
|
16
|
-
}
|
|
17
|
-
function fetchRestCollection(options) {
|
|
18
|
-
const perPage = options.perPage ?? 100;
|
|
19
|
-
if (!Number.isInteger(perPage) || perPage < 1 || perPage > 100) {
|
|
20
|
-
return { ok: false, error: { code: 'PAGINATION_INVALID', message: 'perPage must be between 1 and 100' } };
|
|
21
|
-
}
|
|
22
|
-
let pageIndex = 1;
|
|
23
|
-
let previousHash = null;
|
|
24
|
-
const identities = new Set();
|
|
25
|
-
const items = [];
|
|
26
|
-
const pages = [];
|
|
27
|
-
while (true) {
|
|
28
|
-
let url;
|
|
29
|
-
try {
|
|
30
|
-
url = endpointForPage(options.endpoint, pageIndex, perPage);
|
|
31
|
-
}
|
|
32
|
-
catch (error) {
|
|
33
|
-
return { ok: false, error: { code: 'PAGINATION_INVALID', message: String(error) } };
|
|
34
|
-
}
|
|
35
|
-
const response = options.client.json(['api', url]);
|
|
36
|
-
if (!response.ok)
|
|
37
|
-
return { ok: false, error: response.error };
|
|
38
|
-
if (!Array.isArray(response.value) || response.value.length > perPage) {
|
|
39
|
-
return {
|
|
40
|
-
ok: false,
|
|
41
|
-
error: { code: 'INVALID_PLATFORM_RESPONSE', message: `GitHub page ${pageIndex} is not a valid array page` }
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
let selected;
|
|
45
|
-
try {
|
|
46
|
-
selected = response.value.map((entry) => options.select ? options.select(entry) : entry);
|
|
47
|
-
}
|
|
48
|
-
catch (error) {
|
|
49
|
-
return { ok: false, error: { code: 'INVALID_PLATFORM_RESPONSE', message: String(error) } };
|
|
50
|
-
}
|
|
51
|
-
let bytes;
|
|
52
|
-
try {
|
|
53
|
-
bytes = canonicalJsonBytes(selected);
|
|
54
|
-
}
|
|
55
|
-
catch (error) {
|
|
56
|
-
return { ok: false, error: { code: 'INVALID_PLATFORM_RESPONSE', message: String(error) } };
|
|
57
|
-
}
|
|
58
|
-
const canonicalSha256 = sha256(bytes);
|
|
59
|
-
if (previousHash === canonicalSha256 && response.value.length > 0) {
|
|
60
|
-
return {
|
|
61
|
-
ok: false,
|
|
62
|
-
error: { code: 'PAGINATION_UNSTABLE', message: `GitHub page ${pageIndex} repeats the previous page` }
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
for (const entry of selected) {
|
|
66
|
-
const identity = options.identify(entry);
|
|
67
|
-
if (!identity || identities.has(identity)) {
|
|
68
|
-
return {
|
|
69
|
-
ok: false,
|
|
70
|
-
error: { code: 'PAGINATION_UNSTABLE', message: `duplicate or empty identity on page ${pageIndex}` }
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
identities.add(identity);
|
|
74
|
-
items.push(entry);
|
|
75
|
-
}
|
|
76
|
-
pages.push({ evidence: { index: pageIndex, itemCount: response.value.length, canonicalSha256 }, bytes });
|
|
77
|
-
previousHash = canonicalSha256;
|
|
78
|
-
if (response.value.length < perPage)
|
|
79
|
-
break;
|
|
80
|
-
pageIndex += 1;
|
|
81
|
-
}
|
|
82
|
-
const evidence = {
|
|
83
|
-
endpoint: options.endpoint,
|
|
84
|
-
requestCount: pages.length,
|
|
85
|
-
dataPageCount: pages.filter((page) => page.evidence.itemCount > 0).length,
|
|
86
|
-
itemCount: items.length,
|
|
87
|
-
termination: 'short-page',
|
|
88
|
-
pages: pages.map((page) => page.evidence)
|
|
89
|
-
};
|
|
90
|
-
return {
|
|
91
|
-
ok: true,
|
|
92
|
-
value: {
|
|
93
|
-
items,
|
|
94
|
-
evidence,
|
|
95
|
-
pageObjects: pages.map((page) => ({
|
|
96
|
-
sourceKind: 'github-rest',
|
|
97
|
-
sourceIdentity: `${options.endpoint}#page=${page.evidence.index}`,
|
|
98
|
-
sha256: page.evidence.canonicalSha256,
|
|
99
|
-
bytes: page.bytes.length,
|
|
100
|
-
content: page.bytes.toString('utf8'),
|
|
101
|
-
disposition: { state: 'included' }
|
|
102
|
-
}))
|
|
103
|
-
}
|
|
104
|
-
};
|
|
105
|
-
}
|
|
106
|
-
function relativeIdentity(repoRoot, filePath) {
|
|
107
|
-
const workspaceRoot = resolveProjectTaskWorkspaceRoot(repoRoot);
|
|
108
|
-
const taskRelative = path.relative(workspaceRoot, filePath);
|
|
109
|
-
if (taskRelative && !taskRelative.startsWith('..') && !path.isAbsolute(taskRelative)) {
|
|
110
|
-
return path.posix.join('task-workspace', taskRelative.split(path.sep).join('/'));
|
|
111
|
-
}
|
|
112
|
-
const relative = path.relative(repoRoot, filePath);
|
|
113
|
-
if (!relative || relative.startsWith('..') || path.isAbsolute(relative))
|
|
114
|
-
throw new Error(`path escapes repository: ${filePath}`);
|
|
115
|
-
return relative.split(path.sep).join('/');
|
|
116
|
-
}
|
|
117
|
-
function readStableFile(repoRoot, filePath, sourceKind) {
|
|
118
|
-
const before = fs.lstatSync(filePath);
|
|
119
|
-
if (!before.isFile() || before.isSymbolicLink())
|
|
120
|
-
throw new Error(`unsafe source file: ${filePath}`);
|
|
121
|
-
const content = fs.readFileSync(filePath, 'utf8');
|
|
122
|
-
const after = fs.lstatSync(filePath);
|
|
123
|
-
if (before.dev !== after.dev || before.ino !== after.ino || before.size !== after.size || before.mtimeMs !== after.mtimeMs) {
|
|
124
|
-
throw new Error(`source changed while reading: ${filePath}`);
|
|
125
|
-
}
|
|
126
|
-
return captureText(sourceKind, relativeIdentity(repoRoot, filePath), content);
|
|
127
|
-
}
|
|
128
|
-
function listFiles(directory) {
|
|
129
|
-
if (!fs.existsSync(directory))
|
|
130
|
-
return [];
|
|
131
|
-
const output = [];
|
|
132
|
-
const walk = (current) => {
|
|
133
|
-
for (const entry of fs.readdirSync(current, { withFileTypes: true }).sort((a, b) => a.name.localeCompare(b.name))) {
|
|
134
|
-
const candidate = path.join(current, entry.name);
|
|
135
|
-
if (entry.isSymbolicLink())
|
|
136
|
-
throw new Error(`symlink source is not allowed: ${candidate}`);
|
|
137
|
-
if (entry.isDirectory())
|
|
138
|
-
walk(candidate);
|
|
139
|
-
else if (entry.isFile())
|
|
140
|
-
output.push(candidate);
|
|
141
|
-
}
|
|
142
|
-
};
|
|
143
|
-
walk(directory);
|
|
144
|
-
return output;
|
|
145
|
-
}
|
|
146
|
-
function structuredReceipt(repoRoot, filePath) {
|
|
147
|
-
const raw = readStableFile(repoRoot, filePath, 'structured-telemetry');
|
|
148
|
-
if (!raw.content)
|
|
149
|
-
return raw;
|
|
150
|
-
try {
|
|
151
|
-
const parsed = JSON.parse(raw.content);
|
|
152
|
-
const fields = ['client', 'model', 'reasoning', 'stage', 'toolCategory', 'time', 'status', 'retry', 'error', 'fallback'];
|
|
153
|
-
const selected = Object.fromEntries(fields.filter((field) => parsed[field] !== undefined).map((field) => [field, jsonClone(parsed[field])]));
|
|
154
|
-
selected.sourceSha256 = raw.sha256;
|
|
155
|
-
return captureText('structured-telemetry', raw.sourceIdentity, canonicalJsonBytes(selected).toString('utf8'));
|
|
156
|
-
}
|
|
157
|
-
catch {
|
|
158
|
-
return { ...raw, content: undefined, disposition: { state: 'unavailable', reason: 'invalid receipt JSON' } };
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
function unavailableLog(repoRoot, filePath, includeExcerpts) {
|
|
162
|
-
const raw = readStableFile(repoRoot, filePath, 'local-file');
|
|
163
|
-
if (raw.disposition?.state === 'excluded-sensitive')
|
|
164
|
-
return raw;
|
|
165
|
-
const recognizedBody = /\/(?:sessions?|tools?)(?:\/|[-_])/i.test(raw.sourceIdentity);
|
|
166
|
-
if (includeExcerpts && recognizedBody && raw.content) {
|
|
167
|
-
const excerpt = redactExcerpt(raw.content);
|
|
168
|
-
if (excerpt !== null)
|
|
169
|
-
return captureText('local-file', `${raw.sourceIdentity}#excerpt`, excerpt);
|
|
170
|
-
}
|
|
171
|
-
return {
|
|
172
|
-
sourceKind: 'local-file',
|
|
173
|
-
sourceIdentity: raw.sourceIdentity,
|
|
174
|
-
sha256: raw.sha256,
|
|
175
|
-
bytes: raw.bytes,
|
|
176
|
-
disposition: { state: 'unavailable', reason: recognizedBody ? 'body-excerpts-disabled' : 'unknown-log-format' }
|
|
177
|
-
};
|
|
178
|
-
}
|
|
179
|
-
function collectLocalObjects(repoRoot, options = {}) {
|
|
180
|
-
try {
|
|
181
|
-
const objects = [];
|
|
182
|
-
for (const task of enumerateAllTaskDirs(repoRoot)) {
|
|
183
|
-
for (const filePath of listFiles(task.taskDir)) {
|
|
184
|
-
if (!/\.(?:md|json)$/i.test(filePath))
|
|
185
|
-
continue;
|
|
186
|
-
objects.push(readStableFile(repoRoot, filePath, 'local-file'));
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
const logsRoot = path.join(repoRoot, '.agents', 'workspace', 'logs');
|
|
190
|
-
for (const filePath of listFiles(logsRoot)) {
|
|
191
|
-
if (!/\.(?:md|json)$/i.test(filePath))
|
|
192
|
-
continue;
|
|
193
|
-
const identity = relativeIdentity(repoRoot, filePath);
|
|
194
|
-
if (/\/entropy-check\/.*\.md$/i.test(identity)) {
|
|
195
|
-
objects.push(readStableFile(repoRoot, filePath, 'operational-report'));
|
|
196
|
-
}
|
|
197
|
-
else if (/\/(?:delegation|orchestration)(?:\/|[-_]).*\.json$/i.test(identity)) {
|
|
198
|
-
objects.push(structuredReceipt(repoRoot, filePath));
|
|
199
|
-
}
|
|
200
|
-
else {
|
|
201
|
-
objects.push(unavailableLog(repoRoot, filePath, options.includeExcerpts === true));
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
return { ok: true, value: objects.sort((a, b) => a.sourceIdentity.localeCompare(b.sourceIdentity)) };
|
|
205
|
-
}
|
|
206
|
-
catch (error) {
|
|
207
|
-
return { ok: false, error: { code: 'LOCAL_SOURCE_UNSTABLE', message: error instanceof Error ? error.message : String(error) } };
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
function githubIdentity(item) {
|
|
211
|
-
if (!item || typeof item !== 'object')
|
|
212
|
-
return '';
|
|
213
|
-
const record = item;
|
|
214
|
-
for (const key of ['id', 'node_id', 'sha', 'number']) {
|
|
215
|
-
if (typeof record[key] === 'string' || typeof record[key] === 'number')
|
|
216
|
-
return `${key}:${String(record[key])}`;
|
|
217
|
-
}
|
|
218
|
-
return '';
|
|
219
|
-
}
|
|
220
4
|
function jsonClone(value) {
|
|
221
5
|
return JSON.parse(JSON.stringify(value));
|
|
222
6
|
}
|
|
@@ -323,67 +107,6 @@ function projectGitHubTimelineItem(item) {
|
|
|
323
107
|
output.body = body;
|
|
324
108
|
return output;
|
|
325
109
|
}
|
|
326
|
-
function collectGitHubObjects(repoRoot, client = createGitHubClient()) {
|
|
327
|
-
const repoResult = client.json(['repo', 'view', '--json', 'nameWithOwner'], { cwd: repoRoot });
|
|
328
|
-
if (!repoResult.ok)
|
|
329
|
-
return { ok: false, error: repoResult.error };
|
|
330
|
-
const repository = repoResult.value.nameWithOwner;
|
|
331
|
-
if (!repository || !/^[^/]+\/[^/]+$/.test(repository)) {
|
|
332
|
-
return { ok: false, error: { code: 'INVALID_PLATFORM_RESPONSE', message: 'GitHub repository identity is missing' } };
|
|
333
|
-
}
|
|
334
|
-
const objects = [];
|
|
335
|
-
const evidence = [];
|
|
336
|
-
const captureEndpoint = (endpoint) => {
|
|
337
|
-
const result = fetchRestCollection({
|
|
338
|
-
client,
|
|
339
|
-
endpoint,
|
|
340
|
-
identify: githubIdentity,
|
|
341
|
-
select: (item) => projectGitHubItem(item)
|
|
342
|
-
});
|
|
343
|
-
if (!result.ok)
|
|
344
|
-
return result;
|
|
345
|
-
objects.push(...result.value.pageObjects);
|
|
346
|
-
evidence.push(result.value.evidence);
|
|
347
|
-
return result;
|
|
348
|
-
};
|
|
349
|
-
const issues = captureEndpoint(`repos/${repository}/issues?state=all&sort=created&direction=asc`);
|
|
350
|
-
if (!issues.ok)
|
|
351
|
-
return issues;
|
|
352
|
-
const pulls = captureEndpoint(`repos/${repository}/pulls?state=all&sort=created&direction=asc`);
|
|
353
|
-
if (!pulls.ok)
|
|
354
|
-
return pulls;
|
|
355
|
-
for (const issue of issues.value.items) {
|
|
356
|
-
const number = issue.number;
|
|
357
|
-
if (typeof number !== 'number')
|
|
358
|
-
return { ok: false, error: { code: 'INVALID_PLATFORM_RESPONSE', message: 'Issue number is missing' } };
|
|
359
|
-
const comments = captureEndpoint(`repos/${repository}/issues/${number}/comments`);
|
|
360
|
-
if (!comments.ok)
|
|
361
|
-
return comments;
|
|
362
|
-
}
|
|
363
|
-
for (const pull of pulls.value.items) {
|
|
364
|
-
const record = pull;
|
|
365
|
-
const number = record.number;
|
|
366
|
-
const head = record.head;
|
|
367
|
-
const headSha = head?.sha;
|
|
368
|
-
if (typeof number !== 'number' || typeof headSha !== 'string') {
|
|
369
|
-
return { ok: false, error: { code: 'INVALID_PLATFORM_RESPONSE', message: 'Pull request identity or head SHA is missing' } };
|
|
370
|
-
}
|
|
371
|
-
for (const suffix of ['comments', 'reviews', 'commits']) {
|
|
372
|
-
const nested = captureEndpoint(`repos/${repository}/pulls/${number}/${suffix}`);
|
|
373
|
-
if (!nested.ok)
|
|
374
|
-
return nested;
|
|
375
|
-
}
|
|
376
|
-
const current = client.json(['api', `repos/${repository}/pulls/${number}`]);
|
|
377
|
-
if (!current.ok)
|
|
378
|
-
return { ok: false, error: current.error };
|
|
379
|
-
const projected = projectGitHubItem(current.value);
|
|
380
|
-
const currentHead = projected.head;
|
|
381
|
-
if (currentHead?.sha !== headSha) {
|
|
382
|
-
return { ok: false, error: { code: 'SOURCE_DRIFT', message: `Pull request ${number} head changed during capture` } };
|
|
383
|
-
}
|
|
384
|
-
}
|
|
385
|
-
return { ok: true, value: { repository, objects, endpoints: evidence } };
|
|
386
|
-
}
|
|
387
110
|
function resolveGitHubRepository(repoRoot, client = createGitHubClient()) {
|
|
388
111
|
const result = client.json(['repo', 'view', '--json', 'nameWithOwner'], { cwd: repoRoot });
|
|
389
112
|
if (!result.ok)
|
|
@@ -768,5 +491,5 @@ function collectGitHubBoundary(repoRoot, options = {}) {
|
|
|
768
491
|
}
|
|
769
492
|
};
|
|
770
493
|
}
|
|
771
|
-
export { collectGitHubBoundary,
|
|
494
|
+
export { collectGitHubBoundary, projectGitHubItem, projectGitHubTimelineItem, resolveGitHubRepository };
|
|
772
495
|
//# sourceMappingURL=sources.js.map
|
package/dist/lib/render.js
CHANGED
|
@@ -47,18 +47,6 @@ function containsPlaceholders(src) {
|
|
|
47
47
|
const content = fs.readFileSync(src, 'utf8');
|
|
48
48
|
return content.includes('{{project}}') || content.includes('{{org}}');
|
|
49
49
|
}
|
|
50
|
-
function variantExt(relativePath) {
|
|
51
|
-
return path.extname(relativePath);
|
|
52
|
-
}
|
|
53
|
-
function variantBase(relativePath) {
|
|
54
|
-
const ext = variantExt(relativePath);
|
|
55
|
-
return relativePath.slice(0, -ext.length);
|
|
56
|
-
}
|
|
57
|
-
function withVariant(relativePath, variant) {
|
|
58
|
-
const ext = variantExt(relativePath);
|
|
59
|
-
const base = variantBase(relativePath);
|
|
60
|
-
return `${base}.${variant}${ext}`;
|
|
61
|
-
}
|
|
62
50
|
function stripVariant(relativePath, variant) {
|
|
63
51
|
return relativePath.replace(new RegExp(`\\.${variant.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}\\.`), '.');
|
|
64
52
|
}
|
package/dist/lib/run/index.js
CHANGED
|
@@ -3,7 +3,7 @@ import path from 'node:path';
|
|
|
3
3
|
import { loadServerConfig } from '../server/config.js';
|
|
4
4
|
import { resolveSandboxTarget } from '../sandbox/workspace-identity.js';
|
|
5
5
|
import { createRunId, runInSandbox } from '../sandbox/capture.js';
|
|
6
|
-
import {
|
|
6
|
+
import { normalizeShortIdInput } from '../task/short-id.js';
|
|
7
7
|
import { resolveProjectTaskWorkspaceRoot } from '../task/workspace-root.js';
|
|
8
8
|
import { buildTuiCommand, renderPrompt, selectTui } from './tui.js';
|
|
9
9
|
import { getSkillRunSpec } from './skills.js';
|
|
@@ -72,11 +72,23 @@ function extractHostOptions(args) {
|
|
|
72
72
|
}
|
|
73
73
|
return { positionals, forwarded, skill, taskRef, tui, recreate };
|
|
74
74
|
}
|
|
75
|
+
function parseCreateTaskArgs(skill, options) {
|
|
76
|
+
const { taskRef, recreate, positionals, forwarded, tui } = options;
|
|
77
|
+
if (taskRef !== null)
|
|
78
|
+
throw new Error("create-task does not accept '--task'");
|
|
79
|
+
if (recreate)
|
|
80
|
+
throw new Error('--recreate is only valid for sandbox task runs');
|
|
81
|
+
const createArgs = [...positionals, ...forwarded];
|
|
82
|
+
if (createArgs.length === 0)
|
|
83
|
+
throw new Error('create-task requires a description');
|
|
84
|
+
return { skill, taskRef: null, args: createArgs, tui };
|
|
85
|
+
}
|
|
75
86
|
export function parseRunArgs(args) {
|
|
76
87
|
if (args.length === 0 || args[0] === '--help' || args[0] === '-h') {
|
|
77
88
|
throw new Error(USAGE);
|
|
78
89
|
}
|
|
79
|
-
const
|
|
90
|
+
const options = extractHostOptions(args);
|
|
91
|
+
const { positionals, forwarded, skill, taskRef, tui, recreate } = options;
|
|
80
92
|
if (!skill)
|
|
81
93
|
throw new Error("option '--skill' is required");
|
|
82
94
|
const spec = getSkillRunSpec(skill);
|
|
@@ -87,14 +99,7 @@ export function parseRunArgs(args) {
|
|
|
87
99
|
throw new Error(`Unsupported run route '${routeSelector}'`);
|
|
88
100
|
}
|
|
89
101
|
if (spec.kind === 'create') {
|
|
90
|
-
|
|
91
|
-
throw new Error("create-task does not accept '--task'");
|
|
92
|
-
if (recreate)
|
|
93
|
-
throw new Error('--recreate is only valid for sandbox task runs');
|
|
94
|
-
const createArgs = [...positionals, ...forwarded];
|
|
95
|
-
if (createArgs.length === 0)
|
|
96
|
-
throw new Error('create-task requires a description');
|
|
97
|
-
return { skill, taskRef: null, args: createArgs, tui };
|
|
102
|
+
return parseCreateTaskArgs(skill, options);
|
|
98
103
|
}
|
|
99
104
|
if (positionals.length > 0) {
|
|
100
105
|
throw new Error('ai run requires --skill and --task; positional host arguments are not supported');
|