@kosuke-ai/cli 0.0.9 → 0.0.11

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 (48) hide show
  1. package/dist/index.d.ts +4 -0
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/index.js +51 -0
  4. package/dist/index.js.map +1 -1
  5. package/dist/kosuke/commands/analyse.d.ts.map +1 -1
  6. package/dist/kosuke/commands/analyse.js +52 -94
  7. package/dist/kosuke/commands/analyse.js.map +1 -1
  8. package/dist/kosuke/commands/getcode.d.ts +29 -0
  9. package/dist/kosuke/commands/getcode.d.ts.map +1 -0
  10. package/dist/kosuke/commands/getcode.js +204 -0
  11. package/dist/kosuke/commands/getcode.js.map +1 -0
  12. package/dist/kosuke/commands/lint.d.ts +5 -0
  13. package/dist/kosuke/commands/lint.d.ts.map +1 -1
  14. package/dist/kosuke/commands/lint.js +21 -39
  15. package/dist/kosuke/commands/lint.js.map +1 -1
  16. package/dist/kosuke/commands/requirements.d.ts.map +1 -1
  17. package/dist/kosuke/commands/requirements.js +1 -18
  18. package/dist/kosuke/commands/requirements.js.map +1 -1
  19. package/dist/kosuke/commands/sync-rules.d.ts.map +1 -1
  20. package/dist/kosuke/commands/sync-rules.js +56 -48
  21. package/dist/kosuke/commands/sync-rules.js.map +1 -1
  22. package/dist/kosuke/commands/tickets.d.ts +24 -0
  23. package/dist/kosuke/commands/tickets.d.ts.map +1 -0
  24. package/dist/kosuke/commands/tickets.js +298 -0
  25. package/dist/kosuke/commands/tickets.js.map +1 -0
  26. package/dist/kosuke/types.d.ts +50 -0
  27. package/dist/kosuke/types.d.ts.map +1 -1
  28. package/dist/kosuke/utils/claude-agent.d.ts +57 -0
  29. package/dist/kosuke/utils/claude-agent.d.ts.map +1 -0
  30. package/dist/kosuke/utils/claude-agent.js +177 -0
  31. package/dist/kosuke/utils/claude-agent.js.map +1 -0
  32. package/dist/kosuke/utils/repository-manager.d.ts +13 -0
  33. package/dist/kosuke/utils/repository-manager.d.ts.map +1 -0
  34. package/dist/kosuke/utils/repository-manager.js +94 -0
  35. package/dist/kosuke/utils/repository-manager.js.map +1 -0
  36. package/dist/kosuke/utils/repository-resolver.d.ts +12 -0
  37. package/dist/kosuke/utils/repository-resolver.d.ts.map +1 -0
  38. package/dist/kosuke/utils/repository-resolver.js +186 -0
  39. package/dist/kosuke/utils/repository-resolver.js.map +1 -0
  40. package/dist/kosuke/utils/validator.d.ts +19 -7
  41. package/dist/kosuke/utils/validator.d.ts.map +1 -1
  42. package/dist/kosuke/utils/validator.js +103 -16
  43. package/dist/kosuke/utils/validator.js.map +1 -1
  44. package/dist/lib.d.ts +25 -4
  45. package/dist/lib.d.ts.map +1 -1
  46. package/dist/lib.js +22 -3
  47. package/dist/lib.js.map +1 -1
  48. package/package.json +1 -1
@@ -0,0 +1,94 @@
1
+ /**
2
+ * Repository Manager - Clone and update GitHub repositories
3
+ */
4
+ import simpleGit from 'simple-git';
5
+ import { existsSync, mkdirSync } from 'fs';
6
+ import { join } from 'path';
7
+ const REPOS_DIR = '.tmp/repos';
8
+ /**
9
+ * Ensure repository is cloned and up-to-date
10
+ */
11
+ export async function ensureRepoReady(repoIdentifier) {
12
+ const repoInfo = getRepositoryInfo(repoIdentifier);
13
+ if (existsSync(repoInfo.localPath)) {
14
+ // Repository exists, pull latest changes
15
+ await updateRepository(repoInfo);
16
+ }
17
+ else {
18
+ // Clone repository
19
+ await cloneRepository(repoInfo);
20
+ }
21
+ return repoInfo;
22
+ }
23
+ /**
24
+ * Get repository information
25
+ */
26
+ function getRepositoryInfo(repoIdentifier) {
27
+ const [owner, repo] = repoIdentifier.split('/');
28
+ if (!owner || !repo) {
29
+ throw new Error(`Invalid repository identifier: ${repoIdentifier}`);
30
+ }
31
+ // Replace '/' with '__' to avoid nested directories
32
+ const safeName = repoIdentifier.replace('/', '__');
33
+ const localPath = join(process.cwd(), REPOS_DIR, safeName);
34
+ return {
35
+ owner,
36
+ repo,
37
+ fullName: repoIdentifier,
38
+ localPath,
39
+ };
40
+ }
41
+ /**
42
+ * Clone repository
43
+ */
44
+ async function cloneRepository(repoInfo) {
45
+ console.log(`📥 Cloning ${repoInfo.fullName}...`);
46
+ const git = simpleGit();
47
+ const repoUrl = `https://github.com/${repoInfo.fullName}.git`;
48
+ // Ensure repos directory exists
49
+ const reposDir = join(process.cwd(), REPOS_DIR);
50
+ if (!existsSync(reposDir)) {
51
+ mkdirSync(reposDir, { recursive: true });
52
+ }
53
+ try {
54
+ await git.clone(repoUrl, repoInfo.localPath, [
55
+ '--depth',
56
+ '1', // Shallow clone for faster cloning
57
+ '--single-branch',
58
+ ]);
59
+ console.log(` ✅ Cloned to ${REPOS_DIR}/${repoInfo.fullName.replace('/', '__')}\n`);
60
+ }
61
+ catch (error) {
62
+ throw new Error(`Failed to clone repository ${repoInfo.fullName}:\n` +
63
+ `${error instanceof Error ? error.message : String(error)}\n\n` +
64
+ `Please check:\n` +
65
+ `- Repository exists and is accessible\n` +
66
+ `- You have network connectivity\n` +
67
+ `- Repository name is correct (owner/repo format)`);
68
+ }
69
+ }
70
+ /**
71
+ * Update repository (git pull)
72
+ */
73
+ async function updateRepository(repoInfo) {
74
+ console.log(`🔄 Updating ${repoInfo.fullName}...`);
75
+ const git = simpleGit(repoInfo.localPath);
76
+ try {
77
+ // Fetch and pull latest changes
78
+ await git.fetch(['origin', '--depth', '1']);
79
+ await git.pull('origin', 'HEAD');
80
+ console.log(` ✅ Updated to latest version\n`);
81
+ }
82
+ catch (error) {
83
+ // If update fails, it's not critical - we can use the existing version
84
+ console.warn(` ⚠️ Could not update repository (using cached version):\n ${error instanceof Error ? error.message : String(error)}\n`);
85
+ }
86
+ }
87
+ /**
88
+ * Get local path for a repository (without ensuring it exists)
89
+ */
90
+ export function getRepoLocalPath(repoIdentifier) {
91
+ const safeName = repoIdentifier.replace('/', '__');
92
+ return join(process.cwd(), REPOS_DIR, safeName);
93
+ }
94
+ //# sourceMappingURL=repository-manager.js.map
@@ -0,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,SAAS,CAAC,CAAC;IAErD,IAAI,CAAC;QACH,gCAAgC;QAChC,MAAM,GAAG,CAAC,KAAK,CAAC,CAAC,QAAQ,EAAE,SAAS,EAAE,GAAG,CAAC,CAAC,CAAC;QAC5C,MAAM,GAAG,CAAC,IAAI,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;QAEjC,OAAO,CAAC,GAAG,CAAC,kCAAkC,CAAC,CAAC;IAClD,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,uEAAuE;QACvE,OAAO,CAAC,IAAI,CACV,kEAAkE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAC7H,CAAC;IACJ,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,gBAAgB,CAAC,cAAsB;IACrD,MAAM,QAAQ,GAAG,cAAc,CAAC,OAAO,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;IACnD,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,QAAQ,CAAC,CAAC;AAClD,CAAC"}
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Repository Resolver - Smart repository inference from queries
3
+ */
4
+ /**
5
+ * Resolve repository identifier to owner/repo format
6
+ */
7
+ export declare function resolveRepository(repo: string | undefined, query: string, useTemplate: boolean, githubToken?: string): Promise<string>;
8
+ /**
9
+ * Validate repository access
10
+ */
11
+ export declare function validateRepoAccess(repoIdentifier: string, githubToken?: string): Promise<boolean>;
12
+ //# sourceMappingURL=repository-resolver.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"repository-resolver.d.ts","sourceRoot":"","sources":["../../../kosuke/utils/repository-resolver.ts"],"names":[],"mappings":"AAAA;;GAEG;AAiCH;;GAEG;AACH,wBAAsB,iBAAiB,CACrC,IAAI,EAAE,MAAM,GAAG,SAAS,EACxB,KAAK,EAAE,MAAM,EACb,WAAW,EAAE,OAAO,EACpB,WAAW,CAAC,EAAE,MAAM,GACnB,OAAO,CAAC,MAAM,CAAC,CAiCjB;AA4HD;;GAEG;AACH,wBAAsB,kBAAkB,CACtC,cAAc,EAAE,MAAM,EACtB,WAAW,CAAC,EAAE,MAAM,GACnB,OAAO,CAAC,OAAO,CAAC,CAelB"}
@@ -0,0 +1,186 @@
1
+ /**
2
+ * Repository Resolver - Smart repository inference from queries
3
+ */
4
+ import { Octokit } from '@octokit/rest';
5
+ const KOSUKE_TEMPLATE_REPO = 'Kosuke-Org/kosuke-template';
6
+ const DEFAULT_ORG = 'Kosuke-Org';
7
+ // Well-known repositories mapping
8
+ const WELL_KNOWN_REPOS = {
9
+ nextjs: 'vercel/next.js',
10
+ 'next.js': 'vercel/next.js',
11
+ next: 'vercel/next.js',
12
+ react: 'facebook/react',
13
+ shadcn: 'shadcn/ui',
14
+ 'shadcn-ui': 'shadcn/ui',
15
+ tailwind: 'tailwindlabs/tailwindcss',
16
+ tailwindcss: 'tailwindlabs/tailwindcss',
17
+ prisma: 'prisma/prisma',
18
+ drizzle: 'drizzle-team/drizzle-orm',
19
+ 'drizzle-orm': 'drizzle-team/drizzle-orm',
20
+ trpc: 'trpc/trpc',
21
+ remix: 'remix-run/remix',
22
+ astro: 'withastro/astro',
23
+ svelte: 'sveltejs/svelte',
24
+ vue: 'vuejs/core',
25
+ nuxt: 'nuxt/nuxt',
26
+ angular: 'angular/angular',
27
+ express: 'expressjs/express',
28
+ fastify: 'fastify/fastify',
29
+ nestjs: 'nestjs/nest',
30
+ 'kosuke-template': KOSUKE_TEMPLATE_REPO,
31
+ };
32
+ /**
33
+ * Resolve repository identifier to owner/repo format
34
+ */
35
+ export async function resolveRepository(repo, query, useTemplate, githubToken) {
36
+ // If --template flag is used, always use kosuke-template
37
+ if (useTemplate) {
38
+ return KOSUKE_TEMPLATE_REPO;
39
+ }
40
+ // If repo is explicitly provided, normalize it
41
+ if (repo) {
42
+ return normalizeRepoIdentifier(repo);
43
+ }
44
+ // Try to infer from query
45
+ const inferred = inferRepoFromQuery(query);
46
+ if (inferred) {
47
+ return inferred;
48
+ }
49
+ // If we have a GitHub token, try searching (optional, as per requirement)
50
+ if (githubToken) {
51
+ const searched = await searchGitHubRepo(query, githubToken);
52
+ if (searched) {
53
+ return searched;
54
+ }
55
+ }
56
+ // Could not determine repository
57
+ throw new Error(`Could not determine repository from query: "${query}"\n` +
58
+ `Please specify the repository explicitly:\n` +
59
+ ` kosuke getcode "owner/repo" "${query}"\n` +
60
+ `Or use --template flag for kosuke-template:\n` +
61
+ ` kosuke getcode --template "${query}"`);
62
+ }
63
+ /**
64
+ * Normalize repository identifier to owner/repo format
65
+ */
66
+ function normalizeRepoIdentifier(repo) {
67
+ // Handle GitHub URLs
68
+ const urlPatterns = [
69
+ /github\.com\/([^\/]+)\/([^\/\s]+)/i, // https://github.com/owner/repo
70
+ /github\.com:([^\/]+)\/([^\/\s]+)/i, // git@github.com:owner/repo
71
+ ];
72
+ for (const pattern of urlPatterns) {
73
+ const match = repo.match(pattern);
74
+ if (match) {
75
+ const owner = match[1];
76
+ const repoName = match[2].replace(/\.git$/, ''); // Remove .git suffix
77
+ return `${owner}/${repoName}`;
78
+ }
79
+ }
80
+ // Already in owner/repo format
81
+ if (repo.includes('/')) {
82
+ return repo;
83
+ }
84
+ // Just repo name, assume Kosuke-Org
85
+ if (repo.startsWith('kosuke-')) {
86
+ return `${DEFAULT_ORG}/${repo}`;
87
+ }
88
+ // Can't normalize
89
+ throw new Error(`Invalid repository format: "${repo}"\n` +
90
+ `Expected formats:\n` +
91
+ ` - owner/repo (e.g., "facebook/react")\n` +
92
+ ` - https://github.com/owner/repo\n` +
93
+ ` - kosuke-* (assumes Kosuke-Org/kosuke-*)`);
94
+ }
95
+ /**
96
+ * Extract repository name from user input
97
+ */
98
+ function inferRepoFromQuery(query) {
99
+ const queryLower = query.toLowerCase();
100
+ // Pattern 1: Explicit owner/repo format in query
101
+ const ownerRepoPattern = /\b([a-zA-Z0-9_-]+)\/([a-zA-Z0-9_.-]+)\b/;
102
+ const match = query.match(ownerRepoPattern);
103
+ if (match) {
104
+ return `${match[1]}/${match[2]}`;
105
+ }
106
+ // Pattern 2: Kosuke-specific repos (e.g., "kosuke-template", "kosuke-cli")
107
+ const kosukeRepoPattern = /\b(kosuke-[a-zA-Z0-9_-]+)\b/i;
108
+ const kosukeMatch = query.match(kosukeRepoPattern);
109
+ if (kosukeMatch) {
110
+ return `${DEFAULT_ORG}/${kosukeMatch[1].toLowerCase()}`;
111
+ }
112
+ // Pattern 3: Well-known repositories
113
+ for (const [keyword, repoIdentifier] of Object.entries(WELL_KNOWN_REPOS)) {
114
+ if (queryLower.includes(keyword)) {
115
+ return repoIdentifier;
116
+ }
117
+ }
118
+ return null;
119
+ }
120
+ /**
121
+ * Search GitHub for repository (fallback, requires token)
122
+ */
123
+ async function searchGitHubRepo(query, githubToken) {
124
+ try {
125
+ const octokit = new Octokit({ auth: githubToken });
126
+ // Extract potential repo names from query
127
+ const words = query.match(/\b[a-zA-Z][a-zA-Z0-9_-]{2,}\b/g) || [];
128
+ for (const word of words) {
129
+ // Skip common words
130
+ const skipWords = [
131
+ 'from',
132
+ 'repository',
133
+ 'repo',
134
+ 'code',
135
+ 'implementation',
136
+ 'inspiration',
137
+ 'example',
138
+ 'how',
139
+ 'does',
140
+ 'work',
141
+ 'what',
142
+ 'where',
143
+ 'show',
144
+ 'find',
145
+ ];
146
+ if (skipWords.includes(word.toLowerCase())) {
147
+ continue;
148
+ }
149
+ // Search GitHub
150
+ const { data } = await octokit.search.repos({
151
+ q: word,
152
+ sort: 'stars',
153
+ order: 'desc',
154
+ per_page: 1,
155
+ });
156
+ // Only return if it's a popular repo (>1000 stars)
157
+ if (data.items.length > 0 && data.items[0].stargazers_count > 1000) {
158
+ return data.items[0].full_name;
159
+ }
160
+ }
161
+ }
162
+ catch {
163
+ // Silently fail - this is just a fallback
164
+ console.warn(' ⚠️ GitHub search failed, explicit repo required');
165
+ }
166
+ return null;
167
+ }
168
+ /**
169
+ * Validate repository access
170
+ */
171
+ export async function validateRepoAccess(repoIdentifier, githubToken) {
172
+ if (!githubToken) {
173
+ // Without token, assume public access
174
+ return true;
175
+ }
176
+ try {
177
+ const octokit = new Octokit({ auth: githubToken });
178
+ const [owner, repo] = repoIdentifier.split('/');
179
+ await octokit.repos.get({ owner, repo });
180
+ return true;
181
+ }
182
+ catch {
183
+ return false;
184
+ }
185
+ }
186
+ //# sourceMappingURL=repository-resolver.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"repository-resolver.js","sourceRoot":"","sources":["../../../kosuke/utils/repository-resolver.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAExC,MAAM,oBAAoB,GAAG,4BAA4B,CAAC;AAC1D,MAAM,WAAW,GAAG,YAAY,CAAC;AAEjC,kCAAkC;AAClC,MAAM,gBAAgB,GAA2B;IAC/C,MAAM,EAAE,gBAAgB;IACxB,SAAS,EAAE,gBAAgB;IAC3B,IAAI,EAAE,gBAAgB;IACtB,KAAK,EAAE,gBAAgB;IACvB,MAAM,EAAE,WAAW;IACnB,WAAW,EAAE,WAAW;IACxB,QAAQ,EAAE,0BAA0B;IACpC,WAAW,EAAE,0BAA0B;IACvC,MAAM,EAAE,eAAe;IACvB,OAAO,EAAE,0BAA0B;IACnC,aAAa,EAAE,0BAA0B;IACzC,IAAI,EAAE,WAAW;IACjB,KAAK,EAAE,iBAAiB;IACxB,KAAK,EAAE,iBAAiB;IACxB,MAAM,EAAE,iBAAiB;IACzB,GAAG,EAAE,YAAY;IACjB,IAAI,EAAE,WAAW;IACjB,OAAO,EAAE,iBAAiB;IAC1B,OAAO,EAAE,mBAAmB;IAC5B,OAAO,EAAE,iBAAiB;IAC1B,MAAM,EAAE,aAAa;IACrB,iBAAiB,EAAE,oBAAoB;CACxC,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAi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C,qDAAqD,CAAC,CAAC;IACtE,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CACtC,cAAsB,EACtB,WAAoB;IAEpB,IAAI,CAAC,WAAW,EAAE,CAAC;QACjB,sCAAsC;QACtC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAI,CAAC;QACH,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC,CAAC;QACnD,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC,GAAG,cAAc,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;QAEhD,MAAM,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;QACzC,OAAO,IAAI,CAAC;IACd,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC"}
@@ -1,22 +1,34 @@
1
1
  /**
2
- * Code validation utilities (lint, typecheck)
2
+ * Code validation utilities (lint, typecheck, format)
3
3
  */
4
- interface ValidationResult {
4
+ export interface ValidationResult {
5
5
  success: boolean;
6
6
  output?: string;
7
7
  error?: string;
8
+ warning?: string;
9
+ }
10
+ interface PackageJson {
11
+ scripts?: Record<string, string>;
8
12
  }
9
13
  /**
10
- * Run ESLint with auto-fix
14
+ * Detect package manager based on lock files
11
15
  */
12
- export declare function runLint(): Promise<ValidationResult>;
16
+ export declare function detectPackageManager(cwd?: string): string;
13
17
  /**
14
- * Run TypeScript type checking
18
+ * Read package.json and extract scripts
15
19
  */
16
- export declare function runTypecheck(): Promise<ValidationResult>;
20
+ export declare function readPackageJsonScripts(cwd?: string): PackageJson['scripts'] | null;
17
21
  /**
18
- * Run formatting
22
+ * Run formatting using detected package manager and scripts
19
23
  */
20
24
  export declare function runFormat(): Promise<ValidationResult>;
25
+ /**
26
+ * Run linting using detected package manager and scripts
27
+ */
28
+ export declare function runLint(): Promise<ValidationResult>;
29
+ /**
30
+ * Run TypeScript type checking using detected package manager
31
+ */
32
+ export declare function runTypecheck(): Promise<ValidationResult>;
21
33
  export {};
22
34
  //# sourceMappingURL=validator.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"validator.d.ts","sourceRoot":"","sources":["../../../kosuke/utils/validator.ts"],"names":[],"mappings":"AAAA;;GAEG;AAIH,UAAU,gBAAgB;IACxB,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,wBAAsB,OAAO,IAAI,OAAO,CAAC,gBAAgB,CAAC,CAezD;AAED;;GAEG;AACH,wBAAsB,YAAY,IAAI,OAAO,CAAC,gBAAgB,CAAC,CAe9D;AAED;;GAEG;AACH,wBAAsB,SAAS,IAAI,OAAO,CAAC,gBAAgB,CAAC,CAe3D"}
1
+ {"version":3,"file":"validator.d.ts","sourceRoot":"","sources":["../../../kosuke/utils/validator.ts"],"names":[],"mappings":"AAAA;;GAEG;AAMH,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,UAAU,WAAW;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAClC;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,GAAE,MAAsB,GAAG,MAAM,CAQxE;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,GAAG,GAAE,MAAsB,GAAG,WAAW,CAAC,SAAS,CAAC,GAAG,IAAI,CAcjG;AAED;;GAEG;AACH,wBAAsB,SAAS,IAAI,OAAO,CAAC,gBAAgB,CAAC,CAqC3D;AAED;;GAEG;AACH,wBAAsB,OAAO,IAAI,OAAO,CAAC,gBAAgB,CAAC,CAwCzD;AAED;;GAEG;AACH,wBAAsB,YAAY,IAAI,OAAO,CAAC,gBAAgB,CAAC,CAqC9D"}
@@ -1,14 +1,64 @@
1
1
  /**
2
- * Code validation utilities (lint, typecheck)
2
+ * Code validation utilities (lint, typecheck, format)
3
3
  */
4
4
  import { execSync } from 'child_process';
5
+ import { existsSync, readFileSync } from 'fs';
6
+ import { join } from 'path';
5
7
  /**
6
- * Run ESLint with auto-fix
8
+ * Detect package manager based on lock files
7
9
  */
8
- export async function runLint() {
10
+ export function detectPackageManager(cwd = process.cwd()) {
11
+ if (existsSync(join(cwd, 'bun.lockb')))
12
+ return 'bun';
13
+ if (existsSync(join(cwd, 'pnpm-lock.yaml')))
14
+ return 'pnpm';
15
+ if (existsSync(join(cwd, 'yarn.lock')))
16
+ return 'yarn';
17
+ if (existsSync(join(cwd, 'package-lock.json')))
18
+ return 'npm';
19
+ // Default to npm if no lock file found
20
+ return 'npm';
21
+ }
22
+ /**
23
+ * Read package.json and extract scripts
24
+ */
25
+ export function readPackageJsonScripts(cwd = process.cwd()) {
26
+ const packageJsonPath = join(cwd, 'package.json');
27
+ if (!existsSync(packageJsonPath)) {
28
+ return null;
29
+ }
30
+ try {
31
+ const packageJson = JSON.parse(readFileSync(packageJsonPath, 'utf-8'));
32
+ return packageJson.scripts || null;
33
+ }
34
+ catch (error) {
35
+ console.warn(`⚠️ Failed to parse package.json: ${error}`);
36
+ return null;
37
+ }
38
+ }
39
+ /**
40
+ * Run formatting using detected package manager and scripts
41
+ */
42
+ export async function runFormat() {
43
+ const cwd = process.cwd();
44
+ const scripts = readPackageJsonScripts(cwd);
45
+ if (!scripts) {
46
+ return {
47
+ success: false,
48
+ error: 'package.json not found or has no scripts section',
49
+ };
50
+ }
51
+ if (!scripts.format) {
52
+ return {
53
+ success: true,
54
+ warning: `⚠️ No 'format' script found in package.json. Skipping formatting.\n💡 Hint: kosuke-template uses: "format": "prettier --write ."`,
55
+ };
56
+ }
57
+ const packageManager = detectPackageManager(cwd);
58
+ const command = `${packageManager} run format`;
9
59
  try {
10
- const output = execSync('bun run lint --fix', {
11
- cwd: process.cwd(),
60
+ const output = execSync(command, {
61
+ cwd,
12
62
  encoding: 'utf-8',
13
63
  stdio: 'pipe',
14
64
  });
@@ -16,19 +66,38 @@ export async function runLint() {
16
66
  }
17
67
  catch (error) {
18
68
  const err = error;
69
+ const errorMessage = err.stdout || err.stderr || err.message || '';
19
70
  return {
20
71
  success: false,
21
- error: err.stdout || err.stderr || err.message,
72
+ error: `$ ${command}\n\n${errorMessage}`,
22
73
  };
23
74
  }
24
75
  }
25
76
  /**
26
- * Run TypeScript type checking
77
+ * Run linting using detected package manager and scripts
27
78
  */
28
- export async function runTypecheck() {
79
+ export async function runLint() {
80
+ const cwd = process.cwd();
81
+ const scripts = readPackageJsonScripts(cwd);
82
+ if (!scripts) {
83
+ return {
84
+ success: false,
85
+ error: 'package.json not found or has no scripts section',
86
+ };
87
+ }
88
+ if (!scripts.lint) {
89
+ return {
90
+ success: true,
91
+ warning: `⚠️ No 'lint' script found in package.json. Skipping linting.\n💡 Hint: kosuke-template uses: "lint": "eslint . --ext .js,.jsx,.ts,.tsx --max-warnings 0"`,
92
+ };
93
+ }
94
+ const packageManager = detectPackageManager(cwd);
95
+ // Try to append --fix flag for auto-fixing
96
+ // Note: This works with most linters (eslint, biome, etc.)
97
+ const command = `${packageManager} run lint -- --fix`;
29
98
  try {
30
- const output = execSync('bun run typecheck', {
31
- cwd: process.cwd(),
99
+ const output = execSync(command, {
100
+ cwd,
32
101
  encoding: 'utf-8',
33
102
  stdio: 'pipe',
34
103
  });
@@ -36,19 +105,36 @@ export async function runTypecheck() {
36
105
  }
37
106
  catch (error) {
38
107
  const err = error;
108
+ const errorMessage = err.stdout || err.stderr || err.message || '';
39
109
  return {
40
110
  success: false,
41
- error: err.stdout || err.stderr || err.message,
111
+ error: `$ ${command}\n\n${errorMessage}`,
42
112
  };
43
113
  }
44
114
  }
45
115
  /**
46
- * Run formatting
116
+ * Run TypeScript type checking using detected package manager
47
117
  */
48
- export async function runFormat() {
118
+ export async function runTypecheck() {
119
+ const cwd = process.cwd();
120
+ const scripts = readPackageJsonScripts(cwd);
121
+ if (!scripts) {
122
+ return {
123
+ success: false,
124
+ error: 'package.json not found or has no scripts section',
125
+ };
126
+ }
127
+ if (!scripts.typecheck) {
128
+ return {
129
+ success: true,
130
+ warning: `⚠️ No 'typecheck' script found in package.json. Skipping type checking.\n💡 Hint: kosuke-template uses: "typecheck": "tsc --noEmit"`,
131
+ };
132
+ }
133
+ const packageManager = detectPackageManager(cwd);
134
+ const command = `${packageManager} run typecheck`;
49
135
  try {
50
- const output = execSync('bun run format', {
51
- cwd: process.cwd(),
136
+ const output = execSync(command, {
137
+ cwd,
52
138
  encoding: 'utf-8',
53
139
  stdio: 'pipe',
54
140
  });
@@ -56,9 +142,10 @@ export async function runFormat() {
56
142
  }
57
143
  catch (error) {
58
144
  const err = error;
145
+ const errorMessage = err.stdout || err.stderr || err.message || '';
59
146
  return {
60
147
  success: false,
61
- error: err.stdout || err.stderr || err.message,
148
+ error: `$ ${command}\n\n${errorMessage}`,
62
149
  };
63
150
  }
64
151
  }
@@ -1 +1 @@
1
- {"version":3,"file":"validator.js","sourceRoot":"","sources":["../../../kosuke/utils/validator.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAQzC;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,OAAO;IAC3B,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,QAAQ,CAAC,oBAAoB,EAAE;YAC5C,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE;YAClB,QAAQ,EAAE,OAAO;YACjB,KAAK,EAAE,MAAM;SACd,CAAC,CAAC;QACH,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;IACnC,CAAC;IAAC,OAAO,KAAc,EAAE,C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,CAAC;QACvB,OAAO;YACL,OAAO,EAAE,IAAI;YACb,OAAO,EAAE,sIAAsI;SAChJ,CAAC;IACJ,CAAC;IAED,MAAM,cAAc,GAAG,oBAAoB,CAAC,GAAG,CAAC,CAAC;IACjD,MAAM,OAAO,GAAG,GAAG,cAAc,gBAAgB,CAAC;IAElD,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,QAAQ,CAAC,OAAO,EAAE;YAC/B,GAAG;YACH,QAAQ,EAAE,OAAO;YACjB,KAAK,EAAE,MAAM;SACd,CAAC,CAAC;QACH,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;IACnC,CAAC;IAAC,OAAO,KAAc,EAAE,CAAC;QACxB,MAAM,GAAG,GAAG,KAA+D,CAAC;QAC5E,MAAM,YAAY,GAAG,GAAG,CAAC,MAAM,IAAI,GAAG,CAAC,MAAM,IAAI,GAAG,CAAC,OAAO,IAAI,EAAE,CAAC;QAEnE,OAAO;YACL,OAAO,EAAE,KAAK;YACd,KAAK,EAAE,KAAK,OAAO,OAAO,YAAY,EAAE;SACzC,CAAC;IACJ,CAAC;AACH,CAAC"}
package/dist/lib.d.ts CHANGED
@@ -6,12 +6,27 @@
6
6
  *
7
7
  * @example
8
8
  * ```typescript
9
- * import { analyseCommand, discoverFiles } from '@kosuke-ai/cli';
9
+ * import {
10
+ * analyseCommand,
11
+ * getCodeCore,
12
+ * discoverFiles,
13
+ * runLint,
14
+ * type ValidationResult
15
+ * } from '@kosuke-ai/cli';
10
16
  *
11
17
  * // Run analysis programmatically
12
18
  * await analyseCommand({ scope: 'src', pr: false });
13
19
  *
14
- * // Use utilities
20
+ * // Explore code from a repository
21
+ * const result = await getCodeCore({
22
+ * repo: 'owner/repo',
23
+ * query: 'How does authentication work?'
24
+ * });
25
+ *
26
+ * // Use validation utilities
27
+ * const lintResult: ValidationResult = await runLint();
28
+ *
29
+ * // Discover files
15
30
  * const files = await discoverFiles({ types: ['ts', 'tsx'] });
16
31
  * ```
17
32
  */
@@ -19,8 +34,14 @@ export { analyseCommand } from './kosuke/commands/analyse.js';
19
34
  export { lintCommand } from './kosuke/commands/lint.js';
20
35
  export { syncRulesCommand } from './kosuke/commands/sync-rules.js';
21
36
  export { requirementsCommand } from './kosuke/commands/requirements.js';
37
+ export { getCodeCore } from './kosuke/commands/getcode.js';
38
+ export { ticketsCore } from './kosuke/commands/tickets.js';
22
39
  export { discoverFiles } from './kosuke/utils/file-discovery.js';
23
40
  export { createBatches } from './kosuke/utils/batch-creator.js';
24
- export { runLint, runTypecheck, runFormat } from './kosuke/utils/validator.js';
25
- export type { Batch, Fix, AnalyseOptions, LintOptions, SyncRulesOptions, RulesAdaptation, GitInfo, } from './kosuke/types.js';
41
+ export { runLint, runTypecheck, runFormat, detectPackageManager, readPackageJsonScripts, } from './kosuke/utils/validator.js';
42
+ export { getRepoLocalPath } from './kosuke/utils/repository-manager.js';
43
+ export { validateRepoAccess } from './kosuke/utils/repository-resolver.js';
44
+ export type { Batch, Fix, AnalyseOptions, LintOptions, SyncRulesOptions, RulesAdaptation, GitInfo, GetCodeOptions, CodeExplorationResult, TicketsOptions, TicketsResult, } from './kosuke/types.js';
45
+ export type { ValidationResult } from './kosuke/utils/validator.js';
46
+ export type { AgentVerbosity, AgentConfig, AgentResult } from './kosuke/utils/claude-agent.js';
26
47
  //# sourceMappingURL=lib.d.ts.map
package/dist/lib.d.ts.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"lib.d.ts","sourceRoot":"","sources":["../lib.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAGH,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,EAAE,mBAAmB,EAAE,MAAM,mCAAmC,CAAC;AAGxE,OAAO,EAAE,aAAa,EAAE,MAAM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AAc,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC"}
package/dist/lib.js CHANGED
@@ -6,12 +6,27 @@
6
6
  *
7
7
  * @example
8
8
  * ```typescript
9
- * import { analyseCommand, discoverFiles } from '@kosuke-ai/cli';
9
+ * import {
10
+ * analyseCommand,
11
+ * getCodeCore,
12
+ * discoverFiles,
13
+ * runLint,
14
+ * type ValidationResult
15
+ * } from '@kosuke-ai/cli';
10
16
  *
11
17
  * // Run analysis programmatically
12
18
  * await analyseCommand({ scope: 'src', pr: false });
13
19
  *
14
- * // Use utilities
20
+ * // Explore code from a repository
21
+ * const result = await getCodeCore({
22
+ * repo: 'owner/repo',
23
+ * query: 'How does authentication work?'
24
+ * });
25
+ *
26
+ * // Use validation utilities
27
+ * const lintResult: ValidationResult = await runLint();
28
+ *
29
+ * // Discover files
15
30
  * const files = await discoverFiles({ types: ['ts', 'tsx'] });
16
31
  * ```
17
32
  */
@@ -20,8 +35,12 @@ export { analyseCommand } from './kosuke/commands/analyse.js';
20
35
  export { lintCommand } from './kosuke/commands/lint.js';
21
36
  export { syncRulesCommand } from './kosuke/commands/sync-rules.js';
22
37
  export { requirementsCommand } from './kosuke/commands/requirements.js';
38
+ export { getCodeCore } from './kosuke/commands/getcode.js';
39
+ export { ticketsCore } from './kosuke/commands/tickets.js';
23
40
  // Re-export utilities
24
41
  export { discoverFiles } from './kosuke/utils/file-discovery.js';
25
42
  export { createBatches } from './kosuke/utils/batch-creator.js';
26
- export { runLint, runTypecheck, runFormat } from './kosuke/utils/validator.js';
43
+ export { runLint, runTypecheck, runFormat, detectPackageManager, readPackageJsonScripts, } from './kosuke/utils/validator.js';
44
+ export { getRepoLocalPath } from './kosuke/utils/repository-manager.js';
45
+ export { validateRepoAccess } from './kosuke/utils/repository-resolver.js';
27
46
  //# sourceMappingURL=lib.js.map
package/dist/lib.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"lib.js","sourceRoot":"","sources":["../lib.ts"],"names":[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-1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kosuke-ai/cli",
3
- "version": "0.0.9",
3
+ "version": "0.0.11",
4
4
  "description": "Kosuke CLI - Development automation tool for syncing rules and analyzing code quality",
5
5
  "keywords": [
6
6
  "CLI",