Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
128 commits
Select commit Hold shift + click to select a range
d538a4e
fix: avoid adding empty events or models section in toc (#221)
Ayeshas09 Nov 11, 2025
938ab75
Merge branch 'dev' of https://github.com/apimatic/apimatic-cli into dev
Ayeshas09 Dec 29, 2025
60ac43f
feat: add custom code handling
Ayeshas09 Jan 19, 2026
ccc9739
feat: implement custom code injection
Ayeshas09 Feb 25, 2026
ce55dea
feat: change spec file flag with build
Ayeshas09 Feb 25, 2026
0838a00
feat: update generate sdk to take build as input
Ayeshas09 Feb 26, 2026
c7320a7
handle missing cases in resolve-conflict
Ayeshas09 Feb 27, 2026
a394f07
update sdk generate endpoints and quickstart command
Ayeshas09 Mar 2, 2026
0b64207
use axios to make getSdkStatus call
Ayeshas09 Mar 2, 2026
29ebd97
feat: add multi versioned handling for sdk generate
Ayeshas09 Mar 3, 2026
459bc36
Update launch.json
Ayeshas09 Mar 3, 2026
fe429c4
Update launch.json
Ayeshas09 Mar 3, 2026
84cc713
minor fixes
Ayeshas09 Mar 3, 2026
52e89f4
update the sdk generate controller method name
Ayeshas09 Mar 3, 2026
9062388
resolve merge conflicts
Ayeshas09 Mar 3, 2026
c96e4b4
apply feedback suggestions
Ayeshas09 Mar 3, 2026
ee3f68c
merge base branch
Ayeshas09 Mar 3, 2026
4ff2550
add isomorphic-git dependency and update package-lock
Ayeshas09 Mar 4, 2026
8ca5b77
minor fixes
Ayeshas09 Mar 4, 2026
4e9392f
apply feedback
Ayeshas09 Mar 4, 2026
5aa6437
fix: rename flag to input
aliasghar98 Mar 4, 2026
f0e1fe9
docs(readme): updated readme
aliasghar98 Mar 4, 2026
0180126
fix: flattern errors to display the error message
Ayeshas09 Mar 4, 2026
3cde676
Merge branch 'ayeshas09/update-sdk-generate-command' of https://githu…
Ayeshas09 Mar 4, 2026
8f1bdd3
Merge branch 'ayeshas09/update-sdk-generate-command' into ayeshas09-f…
Ayeshas09 Mar 4, 2026
bcf528a
Merge branch 'beta' into ayeshas09-feat-custom-code
Ayeshas09 Mar 6, 2026
d386b41
revert portal generate changes
Ayeshas09 Mar 9, 2026
e5fbd12
fix generate portal call
Ayeshas09 Mar 9, 2026
d3ab886
update generate sdk command
Ayeshas09 Mar 9, 2026
771136a
update sdk save-changes command
Ayeshas09 Mar 9, 2026
4338cba
update package-lock.json
Ayeshas09 Mar 9, 2026
6a2b63c
utilize the download sdk source tree endpoint
Ayeshas09 Mar 11, 2026
8b70396
refactor
Ayeshas09 Mar 11, 2026
5fc03e4
refactor
Ayeshas09 Mar 12, 2026
a7bf0a7
apply feedback suggestions
Ayeshas09 Mar 13, 2026
ba31f43
Merge branch 'beta' into ayeshas09-feat-custom-code
Ayeshas09 Mar 13, 2026
f5dc9a0
refactor
Ayeshas09 Mar 13, 2026
fa1318b
apply feedback suggestions
Ayeshas09 Mar 13, 2026
5400b0f
minor fixes
Ayeshas09 Mar 13, 2026
62961c7
refactor
Ayeshas09 Mar 13, 2026
fcaabe5
feat: add telemetry events
Ayeshas09 Mar 16, 2026
4702eb2
fix: resolve QA reported issues
Ayeshas09 Mar 17, 2026
b3acdb7
refactor and fix reported issues
Ayeshas09 Mar 25, 2026
48b5026
refactor and minor improvements
Ayeshas09 Mar 25, 2026
7706c92
fix minor issues
Ayeshas09 Mar 26, 2026
2dc85d9
fix formatting issues
Ayeshas09 Mar 26, 2026
750298c
refactor
Ayeshas09 Mar 27, 2026
35a6cb2
Merge branch 'beta' into ayeshas09-feat-custom-code
Ayeshas09 Mar 27, 2026
97ca2e9
apply feedback suggestions
Ayeshas09 Mar 31, 2026
68a2f97
refactor
Ayeshas09 Mar 31, 2026
e55c57d
refactor
Ayeshas09 Mar 31, 2026
1721288
refactor: improvements in code readability
asadali214 Apr 1, 2026
6939bc9
refactor: add language to telemetry events
Ayeshas09 Apr 1, 2026
00c7889
refactor: updates in versioned build resolver
asadali214 Apr 2, 2026
1ba3737
Merge branch 'ayeshas09-feat-custom-code' of https://github.com/apima…
Ayeshas09 Apr 2, 2026
a1a13de
fix sdk save-changes
Ayeshas09 Apr 2, 2026
10df11a
fix lock error
Ayeshas09 Apr 2, 2026
ef877b9
fix: clear dir after git checkout
Ayeshas09 Apr 2, 2026
2277156
merge commit
asadali214 Apr 2, 2026
9b7630e
fix: final-sdk.zip file issue
asadali214 Apr 2, 2026
f02e7c4
fix: sdk generate bug
asadali214 Apr 2, 2026
d16b883
refactor: direct sdk input allowed in save changes
asadali214 Apr 2, 2026
52c25ab
fix: save changes default behavior
asadali214 Apr 2, 2026
5aff935
fix: sdk save changes behaviour
asadali214 Apr 2, 2026
f3059c0
fix: await issue
asadali214 Apr 2, 2026
64302e2
resolve PR comment
asadali214 Apr 2, 2026
d2c30fd
fix: delete .git from sdk
Ayeshas09 Apr 2, 2026
0051dc1
refactor
Ayeshas09 Apr 2, 2026
1592ff9
fix: slow opening of diffs in ide
asadali214 Apr 2, 2026
a28867c
minor refactor
Ayeshas09 Apr 2, 2026
0027f81
refactor
Ayeshas09 Apr 2, 2026
0cc0aab
refactor: separate concerns from gitService that shuould be part of f…
asadali214 Apr 3, 2026
26499b4
fix: adds windows check on normalizeFileLineEndings
asadali214 Apr 3, 2026
96d935f
feat: update code
Shield-Jaguar Apr 3, 2026
91a1254
refactor: remove versionedBuildResolver and its usages
asadali214 Apr 3, 2026
579848a
refactor: convert merge source tree application into a context, impro…
asadali214 Apr 4, 2026
3dded3e
refactor: adds context file
asadali214 Apr 4, 2026
ecb4fa5
improved messaging save changes
asadali214 Apr 5, 2026
35bec9a
fix prompts in save changes
asadali214 Apr 6, 2026
e7985be
resolve PR comments
Ayeshas09 Apr 6, 2026
5cf5ddf
fix: telemetry events are now called from commands only, merge source…
asadali214 Apr 6, 2026
152f26f
refactor: fix tracking flow
asadali214 Apr 7, 2026
8b73774
refactor toTree function
Ayeshas09 Apr 7, 2026
c05555a
Merge branch 'ayeshas09-feat-custom-code' of https://github.com/apima…
Ayeshas09 Apr 7, 2026
e87738d
fix: remove logic from prompt layer
asadali214 Apr 7, 2026
a4d97fe
refactor: launcher service
asadali214 Apr 7, 2026
7f549f7
feat: add ai context to project (#265)
Shield-Jaguar Apr 7, 2026
4e15c76
refactor forceCleanup
Ayeshas09 Apr 7, 2026
f0f01d6
Merge branch 'ayeshas09-feat-custom-code' of https://github.com/apima…
Ayeshas09 Apr 7, 2026
d4f0e83
refactor: get the code reviewed by skills
asadali214 Apr 7, 2026
a33ca69
Merge branch 'ayeshas09-feat-custom-code' of https://github.com/apima…
asadali214 Apr 7, 2026
c0748c4
revert close all applications message
asadali214 Apr 7, 2026
700d3f0
update save changes action for force cleanup
asadali214 Apr 7, 2026
0ac92dd
fix: add improvements on new prompts classes
asadali214 Apr 7, 2026
6abab85
refactor: remove logGenerationError helper and update prompt conventions
Shield-Jaguar Apr 7, 2026
bef1680
checkout to main branch after saving changes and sdk generation
Ayeshas09 Apr 7, 2026
df66536
Merge branch 'ayeshas09-feat-custom-code' of https://github.com/apima…
Ayeshas09 Apr 7, 2026
54893f3
fix: await result.mapAll in sdk generate command
Shield-Jaguar Apr 7, 2026
84de92f
docs: clarify chaining of context method return values is intentional
Shield-Jaguar Apr 7, 2026
4903e2d
fix: resolved pr comments
asadali214 Apr 8, 2026
778a1ed
Merge branch 'ayeshas09-feat-custom-code' of https://github.com/apima…
asadali214 Apr 8, 2026
d119e00
update forceCleanup to pollDeleteDirectory
Ayeshas09 Apr 8, 2026
f5f913f
Merge branch 'ayeshas09-feat-custom-code' of https://github.com/apima…
Ayeshas09 Apr 8, 2026
a52e1da
update prompts for save-changes
Ayeshas09 Apr 8, 2026
e12bf9a
resolved pr comment for tree node generation from directory path
asadali214 Apr 8, 2026
39d797e
Merge branch 'ayeshas09-feat-custom-code' of https://github.com/apima…
asadali214 Apr 8, 2026
4c6c462
fix: service error architechtural issues
asadali214 Apr 8, 2026
82265b6
fix prompt for save-changes
Ayeshas09 Apr 8, 2026
8bbfafb
Merge branch 'ayeshas09-feat-custom-code' of https://github.com/apima…
Ayeshas09 Apr 8, 2026
b2ec26d
remove unused imports
Ayeshas09 Apr 8, 2026
fa6fdb1
fix minor issues
Ayeshas09 Apr 8, 2026
418d3c0
refactor: minor issues resolution
asadali214 Apr 8, 2026
2d93810
add a time limit for polling deleteDirectory
Ayeshas09 Apr 8, 2026
9f6864f
fix: improved prompts language
asadali214 Apr 8, 2026
941a09b
Merge branch 'ayeshas09-feat-custom-code' of https://github.com/apima…
asadali214 Apr 8, 2026
edb5997
rename an arg in fileService
asadali214 Apr 8, 2026
4500662
replace buildContext.getSpecDirectory with buildContext.getSpecContext
asadali214 Apr 8, 2026
52d281d
prompts updated after review
asadali214 Apr 9, 2026
a030ff4
un resolved promises fixed
asadali214 Apr 9, 2026
ede8a73
fix: adds delete failure persists action delay
asadali214 Apr 9, 2026
c2949e4
fix: remove unused import and duplicate semicolons
Shield-Jaguar Apr 9, 2026
ae76b08
fix: renamed events in past tense
asadali214 Apr 9, 2026
f97b179
Merge branch 'ayeshas09-feat-custom-code' of https://github.com/apima…
asadali214 Apr 9, 2026
ffa6484
docs: add event skill, tighten context rules, and refactor sdk genera…
Shield-Jaguar Apr 9, 2026
4641996
fix: a typo in refactoring
asadali214 Apr 9, 2026
a61272e
fix: restore correct method name in SdkContext
Shield-Jaguar Apr 9, 2026
c36c57c
Merge branch 'ayeshas09-feat-custom-code' of https://github.com/apima…
Shield-Jaguar Apr 9, 2026
0c54569
docs(skills): add two missing encapsulation constraints to context skill
Shield-Jaguar Apr 9, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 86 additions & 0 deletions .ai/instructions.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
# APIMatic CLI — Project Instructions

This file provides guidance when working with code in this repository.

## Project Overview

APIMatic CLI (`@apimatic/cli`) — the official CLI for APIMatic, built on oclif v4 with TypeScript ESM. It provides commands for API spec validation/transformation, SDK generation, and documentation portal management.

## Common Commands

```bash
# Build
npm run build # tsc -b → outputs to lib/

# Lint
npm run lint # ESLint on src/**/*.{js,ts}
npm run lint:fix # ESLint with --fix --quiet

# Format
npm run format # Prettier write on src/**/*.{js,ts}

# Test (all)
npm test # tsx + mocha, runs test/**/*.test.ts

# Test (single file)
npx tsx node_modules/mocha/bin/_mocha "test/actions/portal/serve.test.ts" --timeout 99999

# Run CLI locally
node bin/run.js <command>
```

## Architecture — 5-Layer Stack

```
Command → Action → Application → Prompts / Infrastructure → Types
```

1. **Commands** (`src/commands/`) — oclif `Command` subclasses. Parse flags, build `CommandMetadata`, call `intro()` → `action.execute()` → `outro(result)`. No business logic.
2. **Actions** (`src/actions/`) — One per command. Orchestrate use-case: validate inputs via Context objects, coordinate services, return `ActionResult<T>`. Never throw to Command.
3. **Application** (`src/application/`) — Complex reusable domain algorithms (e.g., TOC generators, recipe generators). Pure transformations: data in → data out. No prompts, no API calls.
4. **Prompts** (`src/prompts/`) — All terminal UI via `@clack/prompts`. One class per command mirroring `actions/`. Uses `withSpinner` for async operations. No business logic.
5. **Infrastructure** (`src/infrastructure/`) — I/O adapters: `FileService`, `ZipService`, `NetworkService`, API services in `services/`. All return `Result<T, ServiceError>` (neverthrow).

Supporting: **Types** (`src/types/`) for value objects, context objects, and domain events, **client-utils** for auth credential management, **utils** for pure string helpers, **config** for shared Axios instance, **hooks** (`src/hooks/`) for oclif lifecycle hooks (e.g., command-not-found suggestions), **env-info** (`src/infrastructure/env-info.ts`) singleton for CLI version, user-agent string, and base URL resolution.

## Critical Code Conventions

- **ESM imports with `.js` extension** — even for `.ts` source files: `import { Foo } from "../../types/file/directoryPath.js"`
- **No raw string paths** — use `DirectoryPath`, `FilePath`, `FileName`, `UrlPath` value objects from `src/types/file/`
- **No `console.log`** — all output through `@clack/prompts` via Prompts classes only
- **Error handling**: Services return `Result<T, ServiceError>` (neverthrow); Actions return `ActionResult<T>` (success/failed/cancelled). No uncaught throws above infrastructure.
- **Prompts delegation** — Actions never call `log.*` directly; every message goes through `this.prompts.*`
- **Temp directories** — always use `withDirPath()` wrapper, never `tmp-promise` directly
- **`authKey` typed as `string | null = null`**, not `undefined`
- **Exit via `outro(result)`** — sets `process.exitCode`; never call `process.exit()` directly
- **`ActionResult` variants** — `success()`, `failed()`, `cancelled()`, `stopped()` (for long-running server commands); exit codes 0 / 1 / 130 respectively
- **Constructor pattern**: `private readonly` properties, `public readonly execute = async (...) => { ... }`
- **`static cmdTxt`** on every Command using `format.cmd(...)` for example rendering
- **Commands use `export default class`** — oclif requires default export; actions, prompts, and services use named exports (`export class`)
- **Static fields use `readonly`** — `static readonly summary`, `static readonly description`, `static readonly cmdTxt` on every Command
- **Topic separator is space** — `apimatic portal generate`, not `apimatic portal:generate`
- **Telemetry** — After `outro(result)`, commands optionally track failures via `result.mapAll(() => {}, async () => { await new TelemetryService(configDir).trackEvent(new SomeFailedEvent(...), shell) }, () => {})`. Event classes extend `DomainEvent` (`src/types/events/`). Only the failure callback is populated; success/cancel are no-ops.

## Commit Conventions

Uses [Conventional Commits](https://www.conventionalcommits.org/) enforced by commitlint + husky. Pre-commit runs lint-staged (ESLint + Prettier).

**Do not commit or push automatically.** Always wait for explicit instruction from the user before running `git commit` or `git push`.

## Testing

- **Framework**: mocha + chai (expect style) + sinon + nock + mock-fs
- **Test location**: mirrors source — `test/commands/`, `test/actions/`, `test/application/`
- **HTTP mocking**: nock for API calls
- **Run via tsx** (not ts-node) for ESM compatibility

## Skills

Reference these files for scaffolding new code:

- `.ai/skills/command.md` — Command + Action + Prompts conventions; scaffolding templates and checklists
- `.ai/skills/action.md` — Action class conventions; standard / minimal / delegation variants
- `.ai/skills/context.md` — Context object conventions; output / input / temp / pure variants
- `.ai/skills/prompt.md` — Prompts class conventions; simple / standard / delegation / wizard variants
- `.ai/skills/service.md` — Infrastructure Service conventions; SDK controller / axios-auth / axios-stateless variants
- `.ai/skills/value-object.md` — Value object (rich class) conventions; encapsulation, boundary unwrapping, composition rules
Loading
Loading