@vpxa/aikit 0.1.74 → 0.1.76

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.
Files changed (128) hide show
  1. package/package.json +5 -1
  2. package/packages/cli/dist/index.js +2 -2
  3. package/packages/cli/dist/{init-DQkar6Es.js → init-CuRXmyD9.js} +1 -1
  4. package/packages/cli/dist/scaffold-WMQ2uQ48.js +2 -0
  5. package/packages/cli/dist/{user-CopNWxHP.js → user-vbJwa7x2.js} +1 -1
  6. package/scaffold/dist/adapters/claude-code.mjs +4 -0
  7. package/scaffold/dist/adapters/copilot.mjs +75 -0
  8. package/scaffold/dist/adapters/flows.mjs +1 -0
  9. package/scaffold/dist/adapters/skills.mjs +1 -0
  10. package/scaffold/{compiled → dist/compiled}/flows-data.mjs +304 -446
  11. package/scaffold/{compiled → dist/compiled}/skills-data.mjs +554 -2281
  12. package/scaffold/dist/definitions/agents.mjs +9 -0
  13. package/scaffold/dist/definitions/bodies.mjs +512 -0
  14. package/scaffold/dist/definitions/exclusions.mjs +1 -0
  15. package/scaffold/dist/definitions/hooks.mjs +1 -0
  16. package/scaffold/dist/definitions/models.mjs +1 -0
  17. package/scaffold/dist/definitions/plugins.mjs +1 -0
  18. package/scaffold/dist/definitions/prompts.mjs +225 -0
  19. package/scaffold/dist/definitions/protocols.mjs +835 -0
  20. package/scaffold/dist/definitions/tools.mjs +1 -0
  21. package/packages/cli/dist/scaffold-ukCDW3wQ.js +0 -2
  22. package/scaffold/_preview/agents/Architect-Reviewer-Alpha.agent.md +0 -132
  23. package/scaffold/_preview/agents/Architect-Reviewer-Beta.agent.md +0 -132
  24. package/scaffold/_preview/agents/Code-Reviewer-Alpha.agent.md +0 -112
  25. package/scaffold/_preview/agents/Code-Reviewer-Beta.agent.md +0 -112
  26. package/scaffold/_preview/agents/Debugger.agent.md +0 -412
  27. package/scaffold/_preview/agents/Documenter.agent.md +0 -468
  28. package/scaffold/_preview/agents/Explorer.agent.md +0 -76
  29. package/scaffold/_preview/agents/Frontend.agent.md +0 -440
  30. package/scaffold/_preview/agents/Implementer.agent.md +0 -425
  31. package/scaffold/_preview/agents/Orchestrator.agent.md +0 -452
  32. package/scaffold/_preview/agents/Planner.agent.md +0 -481
  33. package/scaffold/_preview/agents/README.md +0 -57
  34. package/scaffold/_preview/agents/Refactor.agent.md +0 -435
  35. package/scaffold/_preview/agents/Researcher-Alpha.agent.md +0 -151
  36. package/scaffold/_preview/agents/Researcher-Beta.agent.md +0 -152
  37. package/scaffold/_preview/agents/Researcher-Delta.agent.md +0 -153
  38. package/scaffold/_preview/agents/Researcher-Gamma.agent.md +0 -152
  39. package/scaffold/_preview/agents/Security.agent.md +0 -433
  40. package/scaffold/_preview/agents/_shared/architect-reviewer-base.md +0 -104
  41. package/scaffold/_preview/agents/_shared/code-agent-base.md +0 -366
  42. package/scaffold/_preview/agents/_shared/code-reviewer-base.md +0 -87
  43. package/scaffold/_preview/agents/_shared/decision-protocol.md +0 -27
  44. package/scaffold/_preview/agents/_shared/forge-protocol.md +0 -90
  45. package/scaffold/_preview/agents/_shared/researcher-base.md +0 -114
  46. package/scaffold/_preview/agents/templates/adr-template.md +0 -28
  47. package/scaffold/_preview/agents/templates/execution-state.md +0 -26
  48. package/scaffold/_preview/flows/_epilogue/steps/docs-sync/README.md +0 -120
  49. package/scaffold/_preview/flows/aikit-advanced/README.md +0 -70
  50. package/scaffold/_preview/flows/aikit-advanced/steps/design/README.md +0 -178
  51. package/scaffold/_preview/flows/aikit-advanced/steps/execute/README.md +0 -145
  52. package/scaffold/_preview/flows/aikit-advanced/steps/plan/README.md +0 -122
  53. package/scaffold/_preview/flows/aikit-advanced/steps/spec/README.md +0 -121
  54. package/scaffold/_preview/flows/aikit-advanced/steps/task/README.md +0 -119
  55. package/scaffold/_preview/flows/aikit-advanced/steps/verify/README.md +0 -145
  56. package/scaffold/_preview/flows/aikit-basic/README.md +0 -51
  57. package/scaffold/_preview/flows/aikit-basic/steps/assess/README.md +0 -109
  58. package/scaffold/_preview/flows/aikit-basic/steps/design/README.md +0 -116
  59. package/scaffold/_preview/flows/aikit-basic/steps/implement/README.md +0 -131
  60. package/scaffold/_preview/flows/aikit-basic/steps/verify/README.md +0 -123
  61. package/scaffold/_preview/prompts/aikit-ask.prompt.md +0 -13
  62. package/scaffold/_preview/prompts/aikit-debug.prompt.md +0 -15
  63. package/scaffold/_preview/prompts/aikit-design.prompt.md +0 -15
  64. package/scaffold/_preview/prompts/aikit-flow-add.prompt.md +0 -84
  65. package/scaffold/_preview/prompts/aikit-flow-create.prompt.md +0 -80
  66. package/scaffold/_preview/prompts/aikit-flow-manage.prompt.md +0 -24
  67. package/scaffold/_preview/prompts/aikit-implement.prompt.md +0 -17
  68. package/scaffold/_preview/prompts/aikit-plan.prompt.md +0 -15
  69. package/scaffold/_preview/prompts/aikit-review.prompt.md +0 -24
  70. package/scaffold/_preview/skills/adr-skill/SKILL.md +0 -335
  71. package/scaffold/_preview/skills/adr-skill/assets/templates/adr-madr.md +0 -89
  72. package/scaffold/_preview/skills/adr-skill/assets/templates/adr-readme.md +0 -20
  73. package/scaffold/_preview/skills/adr-skill/assets/templates/adr-simple.md +0 -46
  74. package/scaffold/_preview/skills/adr-skill/references/adr-conventions.md +0 -95
  75. package/scaffold/_preview/skills/adr-skill/references/examples.md +0 -193
  76. package/scaffold/_preview/skills/adr-skill/references/review-checklist.md +0 -77
  77. package/scaffold/_preview/skills/adr-skill/references/template-variants.md +0 -52
  78. package/scaffold/_preview/skills/adr-skill/scripts/bootstrap_adr.js +0 -259
  79. package/scaffold/_preview/skills/adr-skill/scripts/new_adr.js +0 -391
  80. package/scaffold/_preview/skills/adr-skill/scripts/set_adr_status.js +0 -169
  81. package/scaffold/_preview/skills/aikit/SKILL.md +0 -754
  82. package/scaffold/_preview/skills/brainstorming/SKILL.md +0 -265
  83. package/scaffold/_preview/skills/brainstorming/spec-document-reviewer-prompt.md +0 -49
  84. package/scaffold/_preview/skills/c4-architecture/SKILL.md +0 -389
  85. package/scaffold/_preview/skills/c4-architecture/references/advanced-patterns.md +0 -552
  86. package/scaffold/_preview/skills/c4-architecture/references/c4-syntax.md +0 -510
  87. package/scaffold/_preview/skills/c4-architecture/references/common-mistakes.md +0 -437
  88. package/scaffold/_preview/skills/c4-architecture/references/html-design-system.md +0 -337
  89. package/scaffold/_preview/skills/c4-architecture/references/html-template.html +0 -627
  90. package/scaffold/_preview/skills/docs/SKILL.md +0 -553
  91. package/scaffold/_preview/skills/docs/references/diataxis-anti-patterns.md +0 -147
  92. package/scaffold/_preview/skills/docs/references/diataxis-compass.md +0 -123
  93. package/scaffold/_preview/skills/docs/references/diataxis-quadrants.md +0 -192
  94. package/scaffold/_preview/skills/docs/references/diataxis-quality.md +0 -76
  95. package/scaffold/_preview/skills/docs/references/diataxis-templates.md +0 -120
  96. package/scaffold/_preview/skills/docs/references/flow-artifacts-guide.md +0 -70
  97. package/scaffold/_preview/skills/docs/references/project-knowledge-gotchas.md +0 -32
  98. package/scaffold/_preview/skills/docs/references/project-knowledge-templates.md +0 -281
  99. package/scaffold/_preview/skills/docs/references/project-knowledge-workflow.md +0 -80
  100. package/scaffold/_preview/skills/frontend-design/SKILL.md +0 -237
  101. package/scaffold/_preview/skills/lesson-learned/SKILL.md +0 -113
  102. package/scaffold/_preview/skills/lesson-learned/references/anti-patterns.md +0 -55
  103. package/scaffold/_preview/skills/lesson-learned/references/se-principles.md +0 -109
  104. package/scaffold/_preview/skills/multi-agents-development/SKILL.md +0 -448
  105. package/scaffold/_preview/skills/multi-agents-development/architecture-review-prompt.md +0 -81
  106. package/scaffold/_preview/skills/multi-agents-development/code-quality-review-prompt.md +0 -91
  107. package/scaffold/_preview/skills/multi-agents-development/implementer-prompt.md +0 -93
  108. package/scaffold/_preview/skills/multi-agents-development/parallel-dispatch-example.md +0 -167
  109. package/scaffold/_preview/skills/multi-agents-development/spec-review-prompt.md +0 -81
  110. package/scaffold/_preview/skills/present/SKILL.md +0 -616
  111. package/scaffold/_preview/skills/react/SKILL.md +0 -309
  112. package/scaffold/_preview/skills/repo-access/SKILL.md +0 -178
  113. package/scaffold/_preview/skills/repo-access/references/error-patterns.md +0 -116
  114. package/scaffold/_preview/skills/repo-access/references/platform-matrix.md +0 -142
  115. package/scaffold/_preview/skills/requirements-clarity/SKILL.md +0 -333
  116. package/scaffold/_preview/skills/session-handoff/SKILL.md +0 -199
  117. package/scaffold/_preview/skills/session-handoff/references/handoff-template.md +0 -139
  118. package/scaffold/_preview/skills/session-handoff/references/resume-checklist.md +0 -80
  119. package/scaffold/_preview/skills/session-handoff/scripts/check_staleness.js +0 -269
  120. package/scaffold/_preview/skills/session-handoff/scripts/create_handoff.js +0 -299
  121. package/scaffold/_preview/skills/session-handoff/scripts/list_handoffs.js +0 -113
  122. package/scaffold/_preview/skills/session-handoff/scripts/validate_handoff.js +0 -241
  123. package/scaffold/_preview/skills/typescript/SKILL.md +0 -405
  124. package/scaffold/adapters/claude-code.mjs +0 -73
  125. package/scaffold/adapters/copilot.mjs +0 -292
  126. package/scaffold/adapters/flows.mjs +0 -27
  127. package/scaffold/adapters/skills.mjs +0 -25
  128. package/scaffold/generate.mjs +0 -92
@@ -1,309 +0,0 @@
1
- ---
2
- name: react
3
- description: "Comprehensive React development patterns — component architecture, React 19 APIs, Server Components, TypeScript integration, and performance optimization."
4
- metadata:
5
- category: domain
6
- domain: react
7
- applicability: on-demand
8
- inputs: [codebase, requirements]
9
- outputs: [component-patterns, code]
10
- relatedSkills: [typescript, frontend-design]
11
- ---
12
-
13
- # React
14
-
15
- > Comprehensive React development patterns — component architecture, React 19 APIs, Server Components, TypeScript integration, and performance optimization. Synthesized from react-dev patterns, react-patterns (React 19), and Vercel React best practices.
16
-
17
- ## When to Use
18
-
19
- **MANDATORY** for the Frontend agent on every React task. Also use when:
20
- - Building React components, hooks, or pages
21
- - Working with Server Components or Server Actions
22
- - Optimizing React performance (re-renders, bundle size, data fetching)
23
- - Reviewing React code for correctness and best practices
24
-
25
- ## React 19 Quick Reference
26
-
27
- | API | Use Case | Key Change |
28
- |-----|----------|------------|
29
- | `ref` as prop | Access DOM/component instance | No more `forwardRef` wrapper |
30
- | `use()` | Read promises/context in render | Replaces `useContext`, enables async |
31
- | `useActionState` | Form submission state + error | Replaces `useFormState` |
32
- | `useOptimistic` | Instant UI feedback | Optimistic updates before server confirms |
33
- | `useTransition` | Non-urgent state updates | `isPending` for loading states |
34
- | `<form action>` | Server Actions in forms | Direct server function binding |
35
- | Server Components | Zero-bundle components | Default in App Router, no `"use client"` |
36
- | Server Actions | Server mutations | `"use server"` functions, form actions |
37
-
38
- ## Component Patterns
39
-
40
- ### Extend Native Elements
41
- ```tsx
42
- type ButtonProps = React.ComponentProps<"button"> & {
43
- variant?: "primary" | "secondary" | "ghost";
44
- size?: "sm" | "md" | "lg";
45
- };
46
-
47
- function Button({ variant = "primary", size = "md", className, ...props }: ButtonProps) {
48
- return <button className={cn(variants[variant], sizes[size], className)} {...props} />;
49
- }
50
- ```
51
-
52
- ### Discriminated Union Props
53
- ```tsx
54
- type ModalProps =
55
- | { variant: "alert"; message: string; onConfirm: () => void }
56
- | { variant: "form"; children: React.ReactNode; onSubmit: (data: FormData) => void };
57
-
58
- function Modal(props: ModalProps) {
59
- switch (props.variant) {
60
- case "alert": return <AlertModal {...props} />;
61
- case "form": return <FormModal {...props} />;
62
- }
63
- }
64
- ```
65
-
66
- ### Generic Components
67
- ```tsx
68
- type TableProps<T> = {
69
- data: T[];
70
- columns: { key: keyof T; header: string; render?: (value: T[keyof T], row: T) => React.ReactNode }[];
71
- onRowClick?: (row: T) => void;
72
- };
73
-
74
- function Table<T extends Record<string, unknown>>({ data, columns, onRowClick }: TableProps<T>) {
75
- // ...
76
- }
77
- ```
78
-
79
- ### Children Typing
80
- ```tsx
81
- // Specific children
82
- type Props = { children: React.ReactElement<TabProps>[] };
83
-
84
- // Render function children
85
- type Props = { children: (data: T) => React.ReactNode };
86
-
87
- // String only
88
- type Props = { children: string };
89
- ```
90
-
91
- ## Ref as Prop (React 19)
92
-
93
- ```tsx
94
- // React 19: pass ref directly, no forwardRef needed
95
- function Input({ ref, ...props }: React.ComponentProps<"input">) {
96
- return <input ref={ref} {...props} />;
97
- }
98
-
99
- // Cleanup function (new in React 19)
100
- function MeasuredDiv({ ref, ...props }: React.ComponentProps<"div">) {
101
- return (
102
- <div
103
- ref={(node) => {
104
- if (node) measureElement(node);
105
- return () => cleanupMeasurement(); // cleanup on unmount
106
- }}
107
- {...props}
108
- />
109
- );
110
- }
111
- ```
112
-
113
- ## Server Components & Actions
114
-
115
- ### Server Component (default — no directive needed)
116
- ```tsx
117
- // app/users/page.tsx — Server Component (default)
118
- import { db } from "@/lib/db";
119
-
120
- export default async function UsersPage() {
121
- const users = await db.query.users.findMany(); // Direct DB access
122
- return <UserList users={users} />; // Pass data to client
123
- }
124
- ```
125
-
126
- ### Client Component (explicit opt-in)
127
- ```tsx
128
- "use client";
129
- import { useState, useOptimistic, useTransition } from "react";
130
-
131
- export function Counter({ initialCount }: { initialCount: number }) {
132
- const [count, setCount] = useState(initialCount);
133
- return <button onClick={() => setCount(c => c + 1)}>{count}</button>;
134
- }
135
- ```
136
-
137
- ### Server Action with Form
138
- ```tsx
139
- // actions.ts
140
- "use server";
141
- import { z } from "zod";
142
-
143
- const schema = z.object({ name: z.string().min(1), email: z.string().email() });
144
-
145
- export async function createUser(_prev: unknown, formData: FormData) {
146
- const result = schema.safeParse(Object.fromEntries(formData));
147
- if (!result.success) return { error: result.error.flatten().fieldErrors };
148
- await db.insert(users).values(result.data);
149
- return { success: true };
150
- }
151
- ```
152
-
153
- ```tsx
154
- "use client";
155
- import { useActionState } from "react";
156
- import { createUser } from "./actions";
157
-
158
- export function CreateUserForm() {
159
- const [state, action, isPending] = useActionState(createUser, null);
160
- return (
161
- <form action={action}>
162
- <input name="name" required />
163
- {state?.error?.name && <p className="text-red-500">{state.error.name}</p>}
164
- <input name="email" type="email" required />
165
- {state?.error?.email && <p className="text-red-500">{state.error.email}</p>}
166
- <button disabled={isPending}>{isPending ? "Creating..." : "Create"}</button>
167
- </form>
168
- );
169
- }
170
- ```
171
-
172
- ### Optimistic Updates
173
- ```tsx
174
- "use client";
175
- import { useOptimistic } from "react";
176
-
177
- function TodoList({ todos, addTodo }: { todos: Todo[]; addTodo: (text: string) => Promise<void> }) {
178
- const [optimisticTodos, addOptimistic] = useOptimistic(
179
- todos,
180
- (state, newTodo: string) => [...state, { id: "temp", text: newTodo, pending: true }]
181
- );
182
-
183
- async function handleAdd(formData: FormData) {
184
- const text = formData.get("text") as string;
185
- addOptimistic(text);
186
- await addTodo(text);
187
- }
188
-
189
- return (
190
- <form action={handleAdd}>
191
- <input name="text" />
192
- <button type="submit">Add</button>
193
- <ul>
194
- {optimisticTodos.map(t => (
195
- <li key={t.id} style={{ opacity: t.pending ? 0.5 : 1 }}>{t.text}</li>
196
- ))}
197
- </ul>
198
- </form>
199
- );
200
- }
201
- ```
202
-
203
- ## Event Handler Types
204
-
205
- ```tsx
206
- // Always use specific event types
207
- onClick: (e: React.MouseEvent<HTMLButtonElement>) => void
208
- onChange: (e: React.ChangeEvent<HTMLInputElement>) => void
209
- onSubmit: (e: React.FormEvent<HTMLFormElement>) => void
210
- onKeyDown: (e: React.KeyboardEvent<HTMLInputElement>) => void
211
- onFocus: (e: React.FocusEvent<HTMLInputElement>) => void
212
- onDrag: (e: React.DragEvent<HTMLDivElement>) => void
213
- ```
214
-
215
- ## Hooks Typing
216
-
217
- ```tsx
218
- // useState with union
219
- const [status, setStatus] = useState<"idle" | "loading" | "error">("idle");
220
-
221
- // useRef for DOM — pass null, get RefObject
222
- const inputRef = useRef<HTMLInputElement>(null);
223
-
224
- // useRef for mutable value — no null, get MutableRefObject
225
- const intervalRef = useRef<number>(0);
226
-
227
- // useReducer with discriminated actions
228
- type Action = { type: "increment" } | { type: "set"; payload: number };
229
- const [count, dispatch] = useReducer((state: number, action: Action) => {
230
- switch (action.type) {
231
- case "increment": return state + 1;
232
- case "set": return action.payload;
233
- }
234
- }, 0);
235
-
236
- // Custom hook: return as const for tuple types
237
- function useToggle(initial = false) {
238
- const [value, setValue] = useState(initial);
239
- const toggle = useCallback(() => setValue(v => !v), []);
240
- return [value, toggle] as const;
241
- }
242
-
243
- // useContext with null guard
244
- const ctx = useContext(ThemeContext);
245
- if (!ctx) throw new Error("useTheme must be used within ThemeProvider");
246
- ```
247
-
248
- ## Performance Rules
249
-
250
- ### Prevent Async Waterfalls
251
- ```tsx
252
- // BAD — sequential fetching
253
- const user = await getUser(id);
254
- const posts = await getPosts(user.id); // Waits for user first
255
- const comments = await getComments(posts[0].id); // Waits for posts
256
-
257
- // GOOD — parallel where possible
258
- const [user, posts] = await Promise.all([getUser(id), getPosts(id)]);
259
- ```
260
-
261
- ### Bundle Size
262
- - `dynamic(() => import("./HeavyComponent"))` — lazy load below-fold components
263
- - Tree-shake: use named exports, avoid `import *`
264
- - Analyze bundle: `@next/bundle-analyzer` to find bloat
265
- - Code-split by route — each page loads only its own JS
266
- - Avoid importing entire libraries: `import { debounce } from "lodash-es"` not `import _ from "lodash"`
267
-
268
- ### Server-Side Performance
269
- - Default to Server Components — zero JS shipped to client
270
- - Stream with Suspense: wrap slow data fetchers in `<Suspense fallback={<Skeleton />}>`
271
- - Cache expensive computations with `"use cache"` directive
272
- - Avoid serializing large objects across server/client boundary
273
-
274
- ### Client-Side Data Fetching
275
- - Use SWR or React Query — automatic caching, revalidation, error retry
276
- - Stale-while-revalidate: show cached data instantly, refresh in background
277
- - Error boundaries: `<ErrorBoundary>` wrapping data-dependent trees
278
- - Prefetch on hover/viewport for likely next navigations
279
-
280
- ### Re-render Optimization
281
- - React Compiler (React 19): auto-memoizes — try this first before manual `useMemo`/`useCallback`
282
- - If no compiler: `useMemo` for expensive computations, `useCallback` for stable function references
283
- - Extract static JSX outside components — constants don't re-create
284
- - Split context: separate frequently-changing state from rarely-changing state
285
- - `React.memo()` on components receiving only primitive props
286
-
287
- ### Rendering Performance
288
- - **Virtualize** lists > 100 items: `@tanstack/react-virtual`, `react-window`
289
- - Defer heavy computations with `useDeferredValue`
290
- - Batch state updates (React 18+ does this automatically in event handlers)
291
- - Avoid reading DOM layout during renders (force sync layout = jank)
292
-
293
- ### Advanced Patterns
294
- - Progressive hydration: load and hydrate components as they enter viewport
295
- - Concurrent features: `useTransition` for non-blocking state updates
296
- - Suspense caching: combine `<Suspense>` with data cache for instant page transitions
297
- - React Compiler adoption: enable gradually, check for unsafe patterns first
298
-
299
- ## Decision Flow
300
-
301
- When implementing a React feature:
302
-
303
- 1. **Server or Client?** → If it uses browser APIs, event handlers, or useState → Client. Everything else → Server.
304
- 2. **Data fetching?** → Server Component for initial data. SWR/React Query for client-side mutations.
305
- 3. **Form?** → Server Action + `useActionState` + Zod validation.
306
- 4. **Optimistic?** → `useOptimistic` for instant feedback.
307
- 5. **Loading?** → `<Suspense>` with skeleton fallback.
308
- 6. **Performance?** → Try React Compiler first. Then manual memo. Then virtualization. Then code splitting.
309
- 7. **Error?** → Error boundaries for rendering errors. try/catch for Server Actions.
@@ -1,178 +0,0 @@
1
- ---
2
- name: repo-access
3
- description: "Progressive repository access recovery for private and enterprise git repositories. Triggered when: (1) git clone/fetch/pull fails with auth errors (401, 403, 404, Permission denied), (2) web_fetch or http tool returns auth failure on repository URLs, (3) user mentions private repo, enterprise repo, or internal repo, (4) user asks to access code from GitHub Enterprise, GitLab Self-Managed, Bitbucket Server, Azure DevOps. Guides through 5-step progressive strategy: anonymous HTTPS, SSH keys, CLI OAuth, PAT, local clone fallback."
4
- metadata:
5
- category: cross-cutting
6
- domain: general
7
- applicability: on-demand
8
- inputs: [git-error, repository-url, platform-context]
9
- outputs: [authenticated-access, recovery-instructions]
10
- requires: []
11
- relatedSkills: [aikit]
12
- argument-hint: "Repository URL or error message"
13
- ---
14
-
15
- # Repository Access Recovery
16
-
17
- Progressively recover repository access for private, enterprise, and internal git hosts without leaking credentials.
18
-
19
- ## When to Activate
20
-
21
- ### Reactive triggers
22
-
23
- - `git clone`, `git fetch`, or `git pull` fails with `401`, `403`, `404`, `Authentication failed`, or `Permission denied (publickey)`.
24
- - `http` diagnostics against a repo endpoint show auth failure or ambiguous private-repo responses.
25
- - `web_fetch` returns login page HTML, SSO redirect, "Sign in", "Page not found", or empty/truncated content for a repo URL.
26
- - Any tool output contains "behind SSO", "SSO required", "SAML", "requires authentication", or similar auth-gate language about a repository.
27
- - A repository URL works in a browser for the user but fails from agent tools or terminal commands.
28
- - **You are about to declare a repo "inaccessible" or "unreachable"** — STOP and activate this skill first.
29
-
30
- ### Proactive triggers
31
-
32
- - The user says the repo is private, enterprise, self-managed, internal, or SSO-protected.
33
- - The repo is hosted on GitHub Enterprise, GitLab Self-Managed, Bitbucket Server/Data Center, Azure DevOps, Gitea, or another custom git host.
34
- - The environment may need browser sign-in, SSH agent setup, or token-based recovery before any code access can work.
35
-
36
- ## When NOT to Activate
37
-
38
- - Public repositories that already clone or read successfully over HTTPS.
39
- - Local-only repositories where no remote auth is involved.
40
- - Problems caused by branch protection, merge conflicts, or rate limiting rather than repository access.
41
-
42
- ## Step 0: Platform Detection & Capability Gate
43
-
44
- Detect platform from the URL, then decide what recovery options are possible in this environment.
45
-
46
- | URL pattern | Platform |
47
- | --- | --- |
48
- | `github.com`, or any GHE host (e.g. `ghe.*`, `github.*`, custom domain) | GitHub / GitHub Enterprise |
49
- | `gitlab.com`, `gitlab.<corp-host>` | GitLab / GitLab Self-Managed |
50
- | `bitbucket.org`, `bitbucket.<corp-host>` | Bitbucket Cloud / Server |
51
- | `dev.azure.com`, `visualstudio.com`, `/_git/` | Azure DevOps |
52
- | anything else with git over HTTPS/SSH | Unknown — ask the user which platform before assuming generic Git |
53
-
54
- - Capability gate: has terminal, has browser, or conversation-only.
55
- - If terminal is unavailable, skip directly to PAT guidance or local clone fallback.
56
- - If browser is unavailable, prefer SSH or pre-created credentials over CLI OAuth.
57
- - If only the `http` tool is available (no terminal, no CLI): use PAT + authenticated API reads (see "Web-Based Code Access" below). This is the zero-dependency path — no `gh`, `glab`, or `az` installation needed.
58
-
59
- For platform-specific details, read `references/platform-matrix.md`.
60
-
61
- ## Strategy Ladder
62
-
63
- ### Step 1: Try HTTPS Anonymous Access
64
-
65
- - Goal: prove the repo is public or already reachable without extra auth.
66
- - What to do: normalize the remote to an HTTPS URL and run `git ls-remote https://...`. If it succeeds, use HTTPS and stop. If it fails with auth-like errors, continue instead of assuming the repo is missing.
67
- - Verify: `git ls-remote <url>`; SUCCESS -> stop, FAIL -> Step 2.
68
-
69
- ### Step 2: Check Existing SSH Keys
70
-
71
- - Goal: reuse working SSH credentials before asking for new secrets.
72
- - What to do: inspect `~/.ssh/` for key files, run `ssh-add -l`, then test host auth with `ssh -T git@{host}`. If SSH works, switch the remote to the SSH URL and continue with that transport.
73
- - Verify: `git ls-remote <ssh-url>`; SUCCESS -> stop, FAIL -> Step 3.
74
-
75
- ### Step 3: Platform CLI OAuth
76
-
77
- - Goal: use the platform's interactive login flow with stored credentials.
78
- - What to do: check whether the matching CLI exists, for example `which gh`, `which glab`, or `which az` (or platform equivalent). If installed, run `{cli} auth login` and let it complete browser or device OAuth, then retry git access.
79
- - **If the CLI is not installed**: do NOT try `npx` — platform CLIs (`gh`, `glab`, `az`) are native binaries, not npm packages. Skip straight to Step 4 (PAT). For file-read-only tasks, the `http` tool with a PAT header is a zero-dependency alternative to any CLI.
80
- - Verify: `git ls-remote <url>`; SUCCESS -> stop, FAIL -> Step 4.
81
-
82
- ### Step 4: Personal Access Token
83
-
84
- - Goal: recover access when SSH and CLI OAuth are unavailable or blocked.
85
- - What to do: ask the user to create a PAT or app password at the platform-specific URL with minimum read scopes only. Have the user provide it through an env var or credential helper, then configure git credentials without embedding the token in the remote URL.
86
- - Verify: `git ls-remote <url>`; SUCCESS -> stop, FAIL -> Step 5.
87
-
88
- ### Step 5: Local Clone Fallback
89
-
90
- - Goal: unblock work when remote auth cannot be completed from the current environment.
91
- - What to do: ask the user to clone the repository on their machine using their normal workflow, then provide the local filesystem path. Use the local checkout as the source of truth for code access.
92
- - Verify: local repo exists and `git rev-parse --show-toplevel` succeeds; SUCCESS -> stop.
93
-
94
- ## Security Rules (HARD GATE)
95
-
96
- - NEVER include a PAT in a git URL; it leaks into shell history, process lists, logs, and config.
97
- - NEVER repeat a user's token value in chat output, summaries, examples, or when relaying tool output that may contain credentials.
98
- - Use env vars, credential helpers, or platform login tools for token delivery.
99
- - Recommend minimum scopes only: read-only repo scopes, not broad write/admin scopes.
100
- - Prefer ephemeral credentials, OAuth/device flows, or short-lived tokens over long-lived PATs.
101
- - When guiding PAT creation, recommend the shortest feasible expiry (7–30 days for task-specific work).
102
-
103
- ## After Access Is Established
104
-
105
- - Remind the user to revoke single-use PATs once the task is complete.
106
- - If credentials were stored via a credential helper, note that they persist until manually removed or the token expires.
107
-
108
- ## Web-Based Code Access (web_fetch / http)
109
-
110
- Agents often use `web_fetch` or `http` to read individual files without a full clone. These requests fail silently on private repos — GitHub returns `404` or login HTML, not an auth error.
111
-
112
- ### Common URL Patterns That Fail on Private Repos
113
-
114
- | URL Pattern | Platform | What Happens |
115
- |---|---|---|
116
- | `raw.githubusercontent.com/{owner}/{repo}/{ref}/{path}` | GitHub | `404` — no auth header accepted |
117
- | `github.com/{owner}/{repo}/blob/{ref}/{path}` | GitHub web view | `200` with login HTML, not code |
118
- | `api.github.com/repos/{owner}/{repo}/contents/{path}` | GitHub API | `404` (the GitHub 404 trap) |
119
- | `<ghe-host>/{owner}/{repo}/*` (any GHE URL) | GitHub Enterprise | `200` with SAML SSO redirect page — body contains "Initiating SAML single sign-on" and redirect to `login.microsoftonline.com` or other IdP |
120
- | `gitlab.com/{owner}/{repo}/-/raw/{ref}/{path}` | GitLab | `401` or login redirect |
121
- | `dev.azure.com/{org}/{project}/_apis/git/repositories/{repo}/items` | Azure DevOps | `401` or `203` non-authoritative |
122
-
123
- ### SAML SSO Detection (CRITICAL)
124
-
125
- GHE instances with SAML SSO return `200 OK` with an HTML body that is NOT the requested content. **This is the most common false-"inaccessible" scenario.** Detect it by checking `web_fetch` output for ANY of these strings:
126
-
127
- - `Initiating SAML single sign-on`
128
- - `login.microsoftonline.com` (Azure AD / Entra ID)
129
- - `You are being redirected to your identity provider`
130
- - `/login?return_to=`
131
- - `SAMLRequest=`
132
- - `RelayState=`
133
-
134
- If ANY of these appear → the repo exists and is accessible, it just needs authentication. This is NOT "inaccessible" — follow the Strategy Ladder.
135
-
136
- ### Recovery: Authenticated API Reads
137
-
138
- When `web_fetch` fails on a private repo URL, switch to authenticated `http` calls:
139
-
140
- 1. **Ensure auth is established first** — walk the Strategy Ladder (Steps 1-4) to get working credentials.
141
- 2. **Use the platform API with auth headers**, not raw/web URLs:
142
-
143
- | Platform | Authenticated file-read endpoint | Auth header |
144
- |---|---|---|
145
- | GitHub / GHE | `http GET https://api.github.com/repos/{owner}/{repo}/contents/{path}?ref={branch}` | `Authorization: token <PAT>` or use `gh api` |
146
- | GitLab | `http GET https://gitlab.com/api/v4/projects/{id}/repository/files/{path}/raw?ref={branch}` | `PRIVATE-TOKEN: <PAT>` |
147
- | Azure DevOps | `http GET https://dev.azure.com/{org}/{project}/_apis/git/repositories/{repo}/items?path={path}&api-version=7.0` | `Authorization: Basic <base64(:PAT)>` |
148
- | Bitbucket | `http GET https://api.bitbucket.org/2.0/repositories/{owner}/{repo}/src/{ref}/{path}` | `Authorization: Bearer <token>` |
149
-
150
- 3. **Prefer `http` over `web_fetch`** for private repos — `http` sends proper headers and returns machine-readable JSON; `web_fetch` gets HTML login pages.
151
- 4. **For bulk reads**, prefer `git clone --depth 1` over many individual API calls — it's faster and avoids rate limits.
152
- 5. **NEVER embed tokens in URLs** — use auth headers via the `http` tool or `gh api` CLI wrapper.
153
-
154
- ### Quick Decision: Clone vs API Read
155
-
156
- | Situation | Preferred method |
157
- |---|---|
158
- | Need 1-3 specific files | Authenticated API via `http` |
159
- | Need to browse/search the repo | `git clone --depth 1` (shallow) |
160
- | Need file history or blame | `git clone` |
161
- | No terminal available | Authenticated API via `http` with PAT |
162
- | Rate-limited on API | `git clone --depth 1` |
163
-
164
- ## Tool Routing
165
-
166
- | Tool | Use |
167
- | --- | --- |
168
- | `git_context` | Check local repo state and confirm a clone or fallback checkout is usable |
169
- | `http` | Probe platform APIs for auth diagnostics AND read file contents from private repos with auth headers |
170
- | `web_fetch` | Only for public repos or after confirming access works; unreliable for private repos (returns HTML, not code) |
171
- | `web_search` | Find current platform-specific auth documentation when the host is unusual or self-managed |
172
- | Terminal | Run git commands, SSH tests, CLI auth flows, and credential-helper setup |
173
-
174
- For detailed error patterns, read `references/error-patterns.md`.
175
-
176
- ## CRITICAL: The GitHub 404 Trap
177
-
178
- GitHub commonly returns `404 Not Found` for private repositories when the caller is unauthenticated or under-authenticated. NEVER conclude that a GitHub repository does not exist from a `404` alone. Treat that response as an authentication signal first, then walk the ladder before declaring the repo missing.
@@ -1,116 +0,0 @@
1
- # Repo Access Error Patterns
2
-
3
- Use this reference to distinguish missing repositories from authentication and policy failures when probing Git hosts.
4
-
5
- ## HTTP Status Code Matrix
6
-
7
- | Platform | No auth (private repo) | Wrong credentials | Rate limited | SSO required |
8
- |---|---|---|---|---|
9
- | GitHub REST API | `404` (TRAP!) | `401` -> `403` | `403` + rate limit body | `403` + `X-GitHub-SSO` header |
10
- | GitHub Web | HTML "Page not found" or login redirect | Login redirect | - | - |
11
- | GitLab | `401` | `401` | `429` | `401` (PAT mandatory) |
12
- | Bitbucket | `403` | `403` | `429` | `403` |
13
- | Azure DevOps | `401` | `401` | - | `401` |
14
-
15
- ## CRITICAL: The GitHub 404 Trap
16
-
17
- GitHub deliberately returns `404`, not `401`, for private repositories accessed without authentication.
18
- This is by design to avoid leaking whether a repository exists.
19
-
20
- - Never conclude a GitHub repository does not exist from an unauthenticated `404`.
21
- - `GET https://api.github.com/repos/{owner}/{repo}` without auth returns `404` for both "repo truly missing" and "repo exists but is private".
22
- - The only reliable disambiguation is an authenticated probe.
23
- - If the same request still returns `404` with valid auth, the repository is truly missing.
24
-
25
- Probe order:
26
-
27
- 1. Try the authenticated API request first.
28
- 2. If it returns `200`, access works.
29
- 3. If it returns `404` without auth context, treat it as ambiguous and recover.
30
- 4. If it returns `404` with known-good auth, treat the repo as missing.
31
-
32
- ## Git CLI Stderr Patterns
33
-
34
- | Error Text Pattern | Platform | Diagnosis | Action |
35
- |---|---|---|---|
36
- | `remote: Repository not found.` | GitHub | Auth failure, not proof the repo is missing | Try auth strategies |
37
- | `git@github.com: Permission denied (publickey).` | GitHub | SSH key not recognized | Check SSH keys, try HTTPS |
38
- | `remote: HTTP Basic: Access denied.` | GitLab | Auth failure, 2FA likely | Use PAT; password auth is blocked with 2FA |
39
- | `error: The requested URL returned error: 403` | Bitbucket | Auth failure | Try app password |
40
- | `TF401019: The Git repository with name or identifier X does not exist` | Azure DevOps | Auth failure or missing repo | Try PAT with Code:Read scope |
41
- | `fatal: Authentication failed for 'https://...'` | Any (HTTPS) | General auth failure | Escalate through the strategy ladder |
42
- | `Permission denied (publickey).` | Any (SSH) | SSH key not recognized | Check `~/.ssh/`, run `ssh-add`, try HTTPS |
43
- | `fatal: Could not read from remote repository.` | Any (SSH) | SSH access denied | Verify the SSH key is added to the platform |
44
- | `unable to access '...': SSL certificate problem` | Any | Self-signed or enterprise CA issue | Ask about local cert config; skip to local clone if needed |
45
-
46
- Treat these stderr strings as direct signals from tool output. Do not reinterpret GitHub's `Repository not found` as a clean existence check.
47
-
48
- ## web_fetch / http Tool Detection
49
-
50
- - `web_fetch` against a private GitHub repo URL often returns HTML with "Page not found" or a login page.
51
- - GitHub web responses can be `200` with a 404-looking body, so `web_fetch` is unreliable for auth diagnosis.
52
- - `http` against the platform API gives machine-readable bodies and real status codes, so use it for probes.
53
- - For `web_fetch` on `github.com`, inspect the body for `Page not found`, `Sign in`, or `/login` links. If present, assume private or auth-gated access and trigger recovery.
54
-
55
- Recommended diagnostic probe:
56
-
57
- ```text
58
- http GET https://api.github.com/repos/{owner}/{repo}
59
- -> 404 + no auth header -> might be private
60
- -> 401 -> explicit auth failure
61
- -> 200 -> repo is public, access works
62
- ```
63
-
64
- ## Edge Cases
65
-
66
- | Edge Case | Signal | Response |
67
- |---|---|---|
68
- | GitHub.com SAML SSO | `403` + `X-GitHub-SSO: required; url=...` | PAT needs SSO authorization for the org |
69
- | GHE SAML SSO (web_fetch) | `200` + body contains `Initiating SAML single sign-on`, redirect to `login.microsoftonline.com` or other IdP | Repo EXISTS and is auth-gated. NOT inaccessible. Use PAT + `http` with auth headers, or `gh auth login --hostname <host>` |
70
- | GHE SAML SSO (http) | `302` redirect to `/login?return_to=...` or IdP URL | Same — repo exists, needs auth. Walk the Strategy Ladder |
71
- | GHE SAML SSO (git CLI) | `fatal: Authentication failed` or credential prompt | `gh auth login --hostname <host>` or PAT via credential helper |
72
-
73
- ## SAML SSO — Detailed Pattern
74
-
75
- GitHub Enterprise instances commonly use SAML SSO via Azure AD (Entra ID), Okta, or other IdPs. When `web_fetch` hits a GHE URL without auth:
76
-
77
- 1. GHE returns `200 OK` (not 401/403!) with an HTML page
78
- 2. The HTML contains `Initiating SAML single sign-on` and a redirect URL to the IdP
79
- 3. The redirect URL includes `SAMLRequest=`, `RelayState=`, and often `login.microsoftonline.com`
80
- 4. The agent sees HTML content and may conclude the repo is "inaccessible" or "behind SSO"
81
-
82
- **Detection strings** (check `web_fetch` output for ANY of these):
83
- ```
84
- Initiating SAML single sign-on
85
- login.microsoftonline.com
86
- You are being redirected to your identity provider
87
- /login?return_to=
88
- SAMLRequest=
89
- RelayState=
90
- ```
91
-
92
- **Correct response:** The repo exists. The `web_fetch` path will never work for SSO-protected GHE. Switch to:
93
- - `gh auth login --hostname <ghe-host>` (if `gh` CLI available)
94
- - PAT + `http` with `Authorization: token <PAT>` against `<ghe-host>/api/v3/repos/{owner}/{repo}/contents/{path}`
95
- - Ask user for local clone if no token can be obtained
96
- | GitLab 2FA enabled | `401` on password auth | PAT is mandatory; 2FA blocks password auth |
97
- | Expired token | `401` after providing a valid-looking PAT | Generate a new token and check expiry |
98
- | GitHub rate limit | `403` + body contains `rate limit` | Not an auth failure; wait or authenticate for a higher limit |
99
- | IP allowlisting | `403` + body mentions IP or org policies | Cannot be fixed programmatically; skip to local clone (Step 5) |
100
- | Fine-grained PAT scope | `403` + `insufficient scope` | Switch to a classic PAT for org repos |
101
- | SSH key not in agent | `Permission denied (publickey)` + key file exists | Run `ssh-add ~/.ssh/id_ed25519` |
102
- | Wrong SSH username | `Permission denied` | Use `git@host`, not `username@host` |
103
- | Deploy key conflict | `key is already in use` | Use a user SSH key or PAT instead |
104
-
105
- ## Escalation Decision Rules
106
-
107
- - Retry the same step for transient failures such as DNS failure, timeout, or `5xx` responses.
108
- - Escalate to the next strategy step for `401`, `403`, `404`, `Permission denied`, `Authentication failed`, or `Access denied`.
109
- - Skip directly to Step 5 (local clone) for IP allowlisting, enterprise SSL certificate issues, or org policy blocks.
110
-
111
- Default interpretation order:
112
-
113
- 1. Prefer API probes over web page fetches.
114
- 2. Treat GitHub `404` as ambiguous until valid auth disproves privacy.
115
- 3. Treat SSH `publickey` errors as key-distribution failures, not repo absence.
116
- 4. Separate rate limits and org policy blocks from authentication failures before escalating.