@skillit/client 0.2.0
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/CHANGELOG.md +32 -0
- package/LICENSE +21 -0
- package/dist/bin.d.ts +3 -0
- package/dist/bin.d.ts.map +1 -0
- package/dist/bin.js +16 -0
- package/dist/bin.js.map +1 -0
- package/dist/commands/init.d.ts +33 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +152 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/refine.d.ts +49 -0
- package/dist/commands/refine.d.ts.map +1 -0
- package/dist/commands/refine.js +201 -0
- package/dist/commands/refine.js.map +1 -0
- package/dist/detect-mode.d.ts +10 -0
- package/dist/detect-mode.d.ts.map +1 -0
- package/dist/detect-mode.js +88 -0
- package/dist/detect-mode.js.map +1 -0
- package/dist/detect-source.d.ts +46 -0
- package/dist/detect-source.d.ts.map +1 -0
- package/dist/detect-source.js +124 -0
- package/dist/detect-source.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +4 -0
- package/dist/index.js.map +1 -0
- package/dist/model/anthropic.d.ts +10 -0
- package/dist/model/anthropic.d.ts.map +1 -0
- package/dist/model/anthropic.js +110 -0
- package/dist/model/anthropic.js.map +1 -0
- package/dist/model/cli/adapters.d.ts +26 -0
- package/dist/model/cli/adapters.d.ts.map +1 -0
- package/dist/model/cli/adapters.js +133 -0
- package/dist/model/cli/adapters.js.map +1 -0
- package/dist/model/cli/cli-client.d.ts +24 -0
- package/dist/model/cli/cli-client.d.ts.map +1 -0
- package/dist/model/cli/cli-client.js +36 -0
- package/dist/model/cli/cli-client.js.map +1 -0
- package/dist/model/cli/run.d.ts +17 -0
- package/dist/model/cli/run.d.ts.map +1 -0
- package/dist/model/cli/run.js +72 -0
- package/dist/model/cli/run.js.map +1 -0
- package/dist/model/model-client-factory.d.ts +16 -0
- package/dist/model/model-client-factory.d.ts.map +1 -0
- package/dist/model/model-client-factory.js +44 -0
- package/dist/model/model-client-factory.js.map +1 -0
- package/dist/model/models.d.ts +4 -0
- package/dist/model/models.d.ts.map +1 -0
- package/dist/model/models.js +8 -0
- package/dist/model/models.js.map +1 -0
- package/package.json +31 -0
- package/scripts/gen-refine-cli-skill.mjs +48 -0
- package/src/__tests__/anthropic-model.test.ts +45 -0
- package/src/__tests__/anthropic-prompt.test.ts +102 -0
- package/src/__tests__/cli-adapters.test.ts +119 -0
- package/src/__tests__/cli-client.test.ts +58 -0
- package/src/__tests__/cli-run.test.ts +52 -0
- package/src/__tests__/detect-mode.test.ts +114 -0
- package/src/__tests__/detect-source.test.ts +158 -0
- package/src/__tests__/fixtures/bin-with-program.mjs +6 -0
- package/src/__tests__/init.test.ts +218 -0
- package/src/__tests__/model-client-factory.test.ts +28 -0
- package/src/__tests__/refine-resolve.test.ts +72 -0
- package/src/bin.ts +18 -0
- package/src/commands/init.ts +207 -0
- package/src/commands/refine.ts +261 -0
- package/src/detect-mode.ts +94 -0
- package/src/detect-source.ts +123 -0
- package/src/index.ts +3 -0
- package/src/model/anthropic.ts +116 -0
- package/src/model/cli/adapters.ts +178 -0
- package/src/model/cli/cli-client.ts +52 -0
- package/src/model/cli/run.ts +83 -0
- package/src/model/model-client-factory.ts +62 -0
- package/src/model/models.ts +7 -0
- package/tsconfig.build.json +9 -0
- package/tsconfig.json +4 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# @skillit/client
|
|
2
|
+
|
|
3
|
+
## 0.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [#41](https://github.com/pradeepmouli/skillit/pull/41) [`989f899`](https://github.com/pradeepmouli/skillit/commit/989f899fd506f422d67c808bce8b5302f11986c6) Thanks [@pradeepmouli](https://github.com/pradeepmouli)! - - fix(client): guard msg.content[0] access — throw on empty or non-text response
|
|
8
|
+
- fix(typedoc/refine): fix JSDoc closer indentation + use async fs I/O in TypeDocRefineSource
|
|
9
|
+
- feat(client): add skillit bin with refine command
|
|
10
|
+
- feat(client): add AnthropicModelClient (Sonnet drafter, Opus reviewer)
|
|
11
|
+
- feat(client): scaffold @skillit/client package
|
|
12
|
+
|
|
13
|
+
- [#53](https://github.com/pradeepmouli/skillit/pull/53) [`95caa9e`](https://github.com/pradeepmouli/skillit/commit/95caa9e1d0ed3e6562470940b857a83bc8e4a37a) Thanks [@pradeepmouli](https://github.com/pradeepmouli)! - `refine` and `init` gain `--model-client api|claude|codex|copilot`: drive the
|
|
14
|
+
audit→draft→review loop through an already-authenticated agent CLI instead of
|
|
15
|
+
the Anthropic API. Per-CLI adapters (claude maps the drafter/reviewer split to
|
|
16
|
+
Sonnet/Opus; codex/copilot use their default model) reuse the existing prompt
|
|
17
|
+
builders and verdict parser; `--model-cli-timeout` bounds each call. Default
|
|
18
|
+
remains `api`.
|
|
19
|
+
|
|
20
|
+
- [#52](https://github.com/pradeepmouli/skillit/pull/52) [`30e9f03`](https://github.com/pradeepmouli/skillit/commit/30e9f03756bb3596e0cf90bb91beb37dd6bb9c18) Thanks [@pradeepmouli](https://github.com/pradeepmouli)! - Multi-source `refine` (CLI), `skillit init`, ast-grep-based JSDoc editing, and guidance injection.
|
|
21
|
+
- **core**: new `refine/ast-edit.ts` wrapping `@ast-grep/napi` — `upsertJsDocTag`/`readJsDocTags` replace the regex/offset JSDoc surgery; `insertJsDocTag` reimplemented on top of it. `RefineSource.guidance?()` and `guidance` on draft/review requests; `refineSkill` threads the source's bundled guidance skill into every draft/review. `audit-score` surfaces CLI command annotation gaps as work items.
|
|
22
|
+
- **cli**: `CliRefineSource` (extract → bundled `skillit-cli-docs` guidance → JSDoc write-back onto the correlated `*Options` interface); commander program loader (`--program file#export` + `bin` auto-find); `*Options` interface JSDoc reader for loop closure.
|
|
23
|
+
- **client**: `refine` is source-aware — `--source cli|mcp|typedoc` with detection from installed `@skillit/*` packages, plus `--program`; `--mcp` no longer globally required. New `skillit init` command: detect project nature → install the matching package → generate the initial skill into top-level `skills/` → refine (CLI path automated; mcp/typedoc print next-step guidance).
|
|
24
|
+
|
|
25
|
+
### Patch Changes
|
|
26
|
+
|
|
27
|
+
- [#54](https://github.com/pradeepmouli/skillit/pull/54) [`314f9b0`](https://github.com/pradeepmouli/skillit/commit/314f9b0218304e40d6fa6da628fcb112d2940912) Thanks [@pradeepmouli](https://github.com/pradeepmouli)! - Rebrand `@to-skills` → `@skillit`: package scope, a single `skillit` CLI (MCP commands now mounted as `skillit mcp …`), bundled skill names (`skillit-cli-docs`/`skillit-docs`/`skillit-mcp-docs`), and the `package.json` config key (`skillit.mcp`). No API or behavior changes.
|
|
28
|
+
|
|
29
|
+
- Updated dependencies [[`989f899`](https://github.com/pradeepmouli/skillit/commit/989f899fd506f422d67c808bce8b5302f11986c6), [`9699e6f`](https://github.com/pradeepmouli/skillit/commit/9699e6f9896f4153ecdad6b1bbc87ead20e773ef), [`30e9f03`](https://github.com/pradeepmouli/skillit/commit/30e9f03756bb3596e0cf90bb91beb37dd6bb9c18), [`314f9b0`](https://github.com/pradeepmouli/skillit/commit/314f9b0218304e40d6fa6da628fcb112d2940912)]:
|
|
30
|
+
- @skillit/cli@0.4.0
|
|
31
|
+
- @skillit/core@1.5.0
|
|
32
|
+
- @skillit/mcp@0.3.0
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024-present Pradeep Mouli
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/bin.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bin.d.ts","sourceRoot":"","sources":["../src/bin.ts"],"names":[],"mappings":""}
|
package/dist/bin.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// packages/client/src/bin.ts
|
|
3
|
+
import { Command } from 'commander';
|
|
4
|
+
import { buildMcpCommand, reportMcpErrorAndExit } from '@skillit/mcp';
|
|
5
|
+
import { buildInitCommand } from './commands/init.js';
|
|
6
|
+
import { buildRefineCommand } from './commands/refine.js';
|
|
7
|
+
const program = new Command('skillit').description('skillit CLI').version('0.1.0');
|
|
8
|
+
program.addCommand(buildRefineCommand());
|
|
9
|
+
program.addCommand(buildInitCommand());
|
|
10
|
+
program.addCommand(buildMcpCommand());
|
|
11
|
+
program.parseAsync(process.argv).catch((err) => {
|
|
12
|
+
// Preserve the mcp exit-code contract for the `skillit mcp …` path; other
|
|
13
|
+
// errors keep the prior generic behavior (stderr message + exit 1).
|
|
14
|
+
reportMcpErrorAndExit(err);
|
|
15
|
+
});
|
|
16
|
+
//# sourceMappingURL=bin.js.map
|
package/dist/bin.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bin.js","sourceRoot":"","sources":["../src/bin.ts"],"names":[],"mappings":";AACA,6BAA6B;AAC7B,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AACtE,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE1D,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC,SAAS,CAAC,CAAC,WAAW,CAAC,aAAa,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;AAEnF,OAAO,CAAC,UAAU,CAAC,kBAAkB,EAAE,CAAC,CAAC;AACzC,OAAO,CAAC,UAAU,CAAC,gBAAgB,EAAE,CAAC,CAAC;AACvC,OAAO,CAAC,UAAU,CAAC,eAAe,EAAE,CAAC,CAAC;AAEtC,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,GAAY,EAAE,EAAE;IACtD,0EAA0E;IAC1E,oEAAoE;IACpE,qBAAqB,CAAC,GAAG,CAAC,CAAC;AAC7B,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import { type RefineSourceKind } from '../detect-source.js';
|
|
3
|
+
import { type RefineCommandOpts } from './refine.js';
|
|
4
|
+
type PackageManager = 'pnpm' | 'yarn' | 'npm';
|
|
5
|
+
/** Options passed to the (CLI-path) skill generator. */
|
|
6
|
+
export interface GenerateSkillOpts {
|
|
7
|
+
/** Project root being initialized. */
|
|
8
|
+
cwd: string;
|
|
9
|
+
/** Resolved project nature. */
|
|
10
|
+
nature: RefineSourceKind;
|
|
11
|
+
/** Skill name (consumer package name, scope stripped). */
|
|
12
|
+
name: string;
|
|
13
|
+
/** Absolute output directory (`<cwd>/<out>`). */
|
|
14
|
+
outDir: string;
|
|
15
|
+
/** `--program <file#export>` entry, if provided. */
|
|
16
|
+
program?: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Injectable side-effecting steps for {@link buildInitCommand}. All optional;
|
|
20
|
+
* real defaults run install / generate / refine. Tests inject stubs so no real
|
|
21
|
+
* install, network, or model call runs.
|
|
22
|
+
*/
|
|
23
|
+
export interface InitDeps {
|
|
24
|
+
/** Install `pkg` as a dev dependency in `cwd` using package manager `pm`. */
|
|
25
|
+
runInstall?(pkg: string, pm: PackageManager, cwd: string): Promise<void>;
|
|
26
|
+
/** Generate the initial skill (CLI path only). */
|
|
27
|
+
generateSkill?(opts: GenerateSkillOpts): Promise<void>;
|
|
28
|
+
/** Dispatch the refine loop for the resolved source. */
|
|
29
|
+
runRefine?(opts: RefineCommandOpts): Promise<void>;
|
|
30
|
+
}
|
|
31
|
+
export declare function buildInitCommand(deps?: InitDeps): Command;
|
|
32
|
+
export {};
|
|
33
|
+
//# sourceMappingURL=init.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAGL,KAAK,gBAAgB,EACtB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAoB,KAAK,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAEvE,KAAK,cAAc,GAAG,MAAM,GAAG,MAAM,GAAG,KAAK,CAAC;AAE9C,wDAAwD;AACxD,MAAM,WAAW,iBAAiB;IAChC,sCAAsC;IACtC,GAAG,EAAE,MAAM,CAAC;IACZ,+BAA+B;IAC/B,MAAM,EAAE,gBAAgB,CAAC;IACzB,0DAA0D;IAC1D,IAAI,EAAE,MAAM,CAAC;IACb,iDAAiD;IACjD,MAAM,EAAE,MAAM,CAAC;IACf,oDAAoD;IACpD,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;;GAIG;AACH,MAAM,WAAW,QAAQ;IACvB,6EAA6E;IAC7E,UAAU,CAAC,CAAC,GAAG,EAAE,MAAM,EAAE,EAAE,EAAE,cAAc,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACzE,kDAAkD;IAClD,aAAa,CAAC,CAAC,IAAI,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACvD,wDAAwD;IACxD,SAAS,CAAC,CAAC,IAAI,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACpD;AAuED,wBAAgB,gBAAgB,CAAC,IAAI,GAAE,QAAa,GAAG,OAAO,CA8F7D"}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
// packages/client/src/commands/init.ts
|
|
2
|
+
import { spawn } from 'node:child_process';
|
|
3
|
+
import { readFile } from 'node:fs/promises';
|
|
4
|
+
import { join } from 'node:path';
|
|
5
|
+
import { Command } from 'commander';
|
|
6
|
+
import { extractCliSkill, loadProgram, writeCliSkill } from '@skillit/cli';
|
|
7
|
+
import { detectPackageManager, detectProjectNature } from '../detect-source.js';
|
|
8
|
+
import { runRefineCommand } from './refine.js';
|
|
9
|
+
const VALID_SOURCES = ['cli', 'mcp', 'typedoc'];
|
|
10
|
+
/** Map a project nature to the `@skillit/*` package that handles it. */
|
|
11
|
+
function natureToPackage(nature) {
|
|
12
|
+
if (nature === 'cli')
|
|
13
|
+
return '@skillit/cli';
|
|
14
|
+
if (nature === 'mcp')
|
|
15
|
+
return '@skillit/mcp';
|
|
16
|
+
return 'typedoc-plugin-skillit';
|
|
17
|
+
}
|
|
18
|
+
/** Build the package manager's add-dev command line (for messaging + spawn). */
|
|
19
|
+
function addDevCommand(pm, pkg) {
|
|
20
|
+
if (pm === 'pnpm')
|
|
21
|
+
return `pnpm add -D ${pkg}`;
|
|
22
|
+
if (pm === 'yarn')
|
|
23
|
+
return `yarn add -D ${pkg}`;
|
|
24
|
+
return `npm install -D ${pkg}`;
|
|
25
|
+
}
|
|
26
|
+
/** Strip a leading `@scope/` from a package name for use as a skill dir name. */
|
|
27
|
+
function skillNameFrom(packageName) {
|
|
28
|
+
const slash = packageName.indexOf('/');
|
|
29
|
+
if (packageName.startsWith('@') && slash !== -1) {
|
|
30
|
+
return packageName.slice(slash + 1);
|
|
31
|
+
}
|
|
32
|
+
return packageName;
|
|
33
|
+
}
|
|
34
|
+
async function readPackageName(cwd) {
|
|
35
|
+
try {
|
|
36
|
+
const raw = await readFile(join(cwd, 'package.json'), 'utf8');
|
|
37
|
+
const pkg = JSON.parse(raw);
|
|
38
|
+
return pkg.name ?? 'skill';
|
|
39
|
+
}
|
|
40
|
+
catch {
|
|
41
|
+
return 'skill';
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
/** Default install: spawn the package manager's add-dev command, cwd-scoped. */
|
|
45
|
+
function defaultRunInstall(pkg, pm, cwd) {
|
|
46
|
+
const command = addDevCommand(pm, pkg);
|
|
47
|
+
const [bin, ...args] = command.split(' ');
|
|
48
|
+
return new Promise((resolve, reject) => {
|
|
49
|
+
const child = spawn(bin, args, { cwd, stdio: 'inherit' });
|
|
50
|
+
child.on('error', reject);
|
|
51
|
+
child.on('close', (code) => {
|
|
52
|
+
if (code === 0)
|
|
53
|
+
resolve();
|
|
54
|
+
else
|
|
55
|
+
reject(new Error(`exited with code ${code}`));
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
/** Default CLI-path skill generation: loadProgram → extractCliSkill → writeCliSkill. */
|
|
60
|
+
async function defaultGenerateSkill(opts) {
|
|
61
|
+
const program = await loadProgram({ program: opts.program, cwd: opts.cwd });
|
|
62
|
+
const skill = await extractCliSkill({ program, metadata: { name: opts.name } });
|
|
63
|
+
writeCliSkill(skill, { outDir: opts.outDir });
|
|
64
|
+
}
|
|
65
|
+
/** Default refine dispatch: reuse the shared refine command body. */
|
|
66
|
+
function defaultRunRefine(opts) {
|
|
67
|
+
return runRefineCommand(opts);
|
|
68
|
+
}
|
|
69
|
+
export function buildInitCommand(deps = {}) {
|
|
70
|
+
const runInstall = deps.runInstall ?? defaultRunInstall;
|
|
71
|
+
const generateSkill = deps.generateSkill ?? defaultGenerateSkill;
|
|
72
|
+
const runRefine = deps.runRefine ?? defaultRunRefine;
|
|
73
|
+
return new Command('init')
|
|
74
|
+
.description('Detect the project, install the right @skillit package, generate + refine a skill')
|
|
75
|
+
.option('--source <kind>', 'cli | mcp | typedoc (auto-detected if omitted)')
|
|
76
|
+
.option('--program <file#export>', 'commander program entry (cli source)')
|
|
77
|
+
.option('--out <dir>', 'output directory for the generated skill', 'skills')
|
|
78
|
+
.option('--model-client <kind>', 'model backend for refine: api | claude | codex | copilot', 'api')
|
|
79
|
+
.option('--model-cli-timeout <ms>', 'per-call timeout for cli model backends (ms)')
|
|
80
|
+
.action(async (opts) => {
|
|
81
|
+
const cwd = process.cwd();
|
|
82
|
+
// 1. Resolve nature: explicit --source wins, else detect.
|
|
83
|
+
let nature;
|
|
84
|
+
if (opts.source !== undefined) {
|
|
85
|
+
if (!VALID_SOURCES.includes(opts.source)) {
|
|
86
|
+
throw new Error(`Invalid --source value: ${opts.source}. Use --source <cli|mcp|typedoc>.`);
|
|
87
|
+
}
|
|
88
|
+
nature = opts.source;
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
nature = await detectProjectNature(cwd);
|
|
92
|
+
}
|
|
93
|
+
// 2 + 3. Map nature → package, install via the detected package manager.
|
|
94
|
+
const pkg = natureToPackage(nature);
|
|
95
|
+
const pm = detectPackageManager(cwd);
|
|
96
|
+
const command = addDevCommand(pm, pkg);
|
|
97
|
+
try {
|
|
98
|
+
await runInstall(pkg, pm, cwd);
|
|
99
|
+
}
|
|
100
|
+
catch (error) {
|
|
101
|
+
const reason = error instanceof Error ? error.message : String(error);
|
|
102
|
+
// Surface the exact command and STOP — do not generate or refine.
|
|
103
|
+
throw new Error(`Install failed (${reason}). Run it manually:\n ${command}`);
|
|
104
|
+
}
|
|
105
|
+
// 4 + 5. Generate + refine — CLI-first: only the cli source is fully
|
|
106
|
+
// automated this pass. For mcp/typedoc, skip both and print actionable
|
|
107
|
+
// next-step guidance rather than silently no-opping (refine needs
|
|
108
|
+
// source-specific flags like --mcp that init can't supply yet).
|
|
109
|
+
if (nature === 'cli') {
|
|
110
|
+
const outDir = join(cwd, opts.out);
|
|
111
|
+
const name = skillNameFrom(await readPackageName(cwd));
|
|
112
|
+
const generateOpts = {
|
|
113
|
+
cwd,
|
|
114
|
+
nature,
|
|
115
|
+
name,
|
|
116
|
+
outDir,
|
|
117
|
+
...(opts.program !== undefined ? { program: opts.program } : {})
|
|
118
|
+
};
|
|
119
|
+
try {
|
|
120
|
+
await generateSkill(generateOpts);
|
|
121
|
+
}
|
|
122
|
+
catch (error) {
|
|
123
|
+
// The cli source only auto-loads a commander program. A yargs/other
|
|
124
|
+
// CLI (still classified as 'cli') can't be generated yet — degrade
|
|
125
|
+
// gracefully: surface the reason and how to proceed, do NOT crash,
|
|
126
|
+
// and do NOT run refine/regenerate on a failed generate.
|
|
127
|
+
const reason = error instanceof Error ? error.message : String(error);
|
|
128
|
+
console.log(`Installed ${pkg}, but couldn't auto-load a commander program (${reason}). ` +
|
|
129
|
+
`If this is a commander CLI, run: skillit refine --source cli --program <file#export>. ` +
|
|
130
|
+
`(yargs/other CLIs aren't auto-generated yet.)`);
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
await runRefine({
|
|
134
|
+
source: nature,
|
|
135
|
+
...(opts.program !== undefined ? { program: opts.program } : {}),
|
|
136
|
+
...(opts.modelClient !== undefined ? { modelClient: opts.modelClient } : {}),
|
|
137
|
+
...(opts.modelCliTimeout !== undefined ? { modelCliTimeout: opts.modelCliTimeout } : {}),
|
|
138
|
+
maxIterations: '5',
|
|
139
|
+
items: '5'
|
|
140
|
+
});
|
|
141
|
+
// refine only writes JSDoc back into source files; regenerate so the
|
|
142
|
+
// on-disk skill reflects the freshly-written annotations. Runs only
|
|
143
|
+
// after a successful refine (a refine throw propagates above).
|
|
144
|
+
await generateSkill(generateOpts);
|
|
145
|
+
}
|
|
146
|
+
else {
|
|
147
|
+
const extra = nature === 'mcp' ? ' [--mcp <path>]' : '';
|
|
148
|
+
console.log(`Installed ${pkg}. Skill generation + refine for the ${nature} source isn't automated yet — run: skillit refine --source ${nature}${extra}`);
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
//# sourceMappingURL=init.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init.js","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":"AAAA,uCAAuC;AACvC,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,eAAe,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC3E,OAAO,EACL,oBAAoB,EACpB,mBAAmB,EAEpB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,gBAAgB,EAA0B,MAAM,aAAa,CAAC;AAwCvE,MAAM,aAAa,GAAgC,CAAC,KAAK,EAAE,KAAK,EAAE,SAAS,CAAC,CAAC;AAE7E,wEAAwE;AACxE,SAAS,eAAe,CAAC,MAAwB;IAC/C,IAAI,MAAM,KAAK,KAAK;QAAE,OAAO,cAAc,CAAC;IAC5C,IAAI,MAAM,KAAK,KAAK;QAAE,OAAO,cAAc,CAAC;IAC5C,OAAO,wBAAwB,CAAC;AAClC,CAAC;AAED,gFAAgF;AAChF,SAAS,aAAa,CAAC,EAAkB,EAAE,GAAW;IACpD,IAAI,EAAE,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AC;gBAC5E,GAAG,CAAC,IAAI,CAAC,eAAe,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,eAAe,EAAE,IAAI,CAAC,eAAe,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;gBACxF,aAAa,EAAE,GAAG;gBAClB,KAAK,EAAE,GAAG;aACX,CAAC,CAAC;YACH,qEAAqE;YACrE,oEAAoE;YACpE,+DAA+D;YAC/D,MAAM,aAAa,CAAC,YAAY,CAAC,CAAC;QACpC,CAAC;aAAM,CAAC;YACN,MAAM,KAAK,GAAG,MAAM,KAAK,KAAK,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,EAAE,CAAC;YACxD,OAAO,CAAC,GAAG,CACT,aAAa,GAAG,uCAAuC,MAAM,8DAA8D,MAAM,GAAG,KAAK,EAAE,CAC5I,CAAC;QACJ,CAAC;IACH,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import { type DetectedRefineSource, type RefineSourceKind } from '../detect-source.js';
|
|
3
|
+
/** Options consulted by {@link resolveRefineSource}. */
|
|
4
|
+
export interface RefineSourceResolveOpts {
|
|
5
|
+
source?: string;
|
|
6
|
+
mcp?: string;
|
|
7
|
+
}
|
|
8
|
+
/** Result of resolving the refine source: a concrete kind or an actionable error. */
|
|
9
|
+
export type RefineSourceResolution = {
|
|
10
|
+
kind: 'cli' | 'mcp';
|
|
11
|
+
} | {
|
|
12
|
+
error: string;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Resolve the refine source from explicit `--source` (wins) or detection,
|
|
16
|
+
* then validate per-source flag requirements. Pure and unit-testable: it does
|
|
17
|
+
* not read the filesystem or invoke the model.
|
|
18
|
+
*
|
|
19
|
+
* @param opts - parsed `--source` / `--mcp` flags
|
|
20
|
+
* @param detected - result of {@link detectRefineSource} for the cwd
|
|
21
|
+
* @param candidates - the raw installed source kinds (from
|
|
22
|
+
* {@link detectInstalledSources}); named in the ambiguous error
|
|
23
|
+
*/
|
|
24
|
+
export declare function resolveRefineSource(opts: RefineSourceResolveOpts, detected: DetectedRefineSource, candidates?: readonly RefineSourceKind[]): RefineSourceResolution;
|
|
25
|
+
/** Parsed options for the `refine` action / {@link runRefineCommand}. */
|
|
26
|
+
export interface RefineCommandOpts {
|
|
27
|
+
source?: string;
|
|
28
|
+
program?: string;
|
|
29
|
+
mcp?: string;
|
|
30
|
+
server?: string;
|
|
31
|
+
overlay?: string;
|
|
32
|
+
mode?: string;
|
|
33
|
+
sourceGlob?: string;
|
|
34
|
+
maxIterations: string;
|
|
35
|
+
items: string;
|
|
36
|
+
modelClient?: string;
|
|
37
|
+
modelCliTimeout?: string;
|
|
38
|
+
}
|
|
39
|
+
/** The model backend to use; defaults to the API client. */
|
|
40
|
+
export declare function resolveModelClientKind(raw: string | undefined): string;
|
|
41
|
+
/**
|
|
42
|
+
* The body of the `refine` command action, extracted so it can be reused
|
|
43
|
+
* programmatically (e.g. by `skillit init`) without argv gymnastics. Sets
|
|
44
|
+
* `process.exitCode` and writes progress/errors to the console exactly as the
|
|
45
|
+
* CLI does.
|
|
46
|
+
*/
|
|
47
|
+
export declare function runRefineCommand(opts: RefineCommandOpts): Promise<void>;
|
|
48
|
+
export declare function buildRefineCommand(): Command;
|
|
49
|
+
//# sourceMappingURL=refine.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"refine.d.ts","sourceRoot":"","sources":["../../src/commands/refine.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAWpC,OAAO,EAGL,KAAK,oBAAoB,EACzB,KAAK,gBAAgB,EACtB,MAAM,qBAAqB,CAAC;AAW7B,wDAAwD;AACxD,MAAM,WAAW,uBAAuB;IACtC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED,qFAAqF;AACrF,MAAM,MAAM,sBAAsB,GAAG;IAAE,IAAI,EAAE,KAAK,GAAG,KAAK,CAAA;CAAE,GAAG;IAAE,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAKjF;;;;;;;;;GASG;AACH,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,uBAAuB,EAC7B,QAAQ,EAAE,oBAAoB,EAC9B,UAAU,GAAE,SAAS,gBAAgB,EAAO,GAC3C,sBAAsB,CA4BxB;AAED,yEAAyE;AACzE,MAAM,WAAW,iBAAiB;IAChC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,MAAM,CAAC;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B;AAED,4DAA4D;AAC5D,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAEtE;AAED;;;;;GAKG;AACH,wBAAsB,gBAAgB,CAAC,IAAI,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC,CAoG7E;AAED,wBAAgB,kBAAkB,IAAI,OAAO,CAe5C"}
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
// packages/client/src/commands/refine.ts
|
|
2
|
+
import { Command } from 'commander';
|
|
3
|
+
import { McpRefineSource, TypeScriptMcpRefineSource, extractMcpSkill, readMcpConfigFile } from '@skillit/mcp';
|
|
4
|
+
import { CliRefineSource, loadProgram } from '@skillit/cli';
|
|
5
|
+
import { refineSkill } from '@skillit/core';
|
|
6
|
+
import { createModelClient } from '../model/model-client-factory.js';
|
|
7
|
+
import { detectRefineMode } from '../detect-mode.js';
|
|
8
|
+
import { classifyRefineSources, detectInstalledSources } from '../detect-source.js';
|
|
9
|
+
import { join } from 'node:path';
|
|
10
|
+
function parsePositiveInt(raw, flag) {
|
|
11
|
+
const n = parseInt(raw, 10);
|
|
12
|
+
if (!Number.isFinite(n) || n < 1) {
|
|
13
|
+
throw new Error(`${flag} must be a positive integer, got: ${raw}`);
|
|
14
|
+
}
|
|
15
|
+
return n;
|
|
16
|
+
}
|
|
17
|
+
const VALID_SOURCES = ['cli', 'mcp', 'typedoc'];
|
|
18
|
+
const SOURCE_FORM = '--source <cli|mcp|typedoc>';
|
|
19
|
+
/**
|
|
20
|
+
* Resolve the refine source from explicit `--source` (wins) or detection,
|
|
21
|
+
* then validate per-source flag requirements. Pure and unit-testable: it does
|
|
22
|
+
* not read the filesystem or invoke the model.
|
|
23
|
+
*
|
|
24
|
+
* @param opts - parsed `--source` / `--mcp` flags
|
|
25
|
+
* @param detected - result of {@link detectRefineSource} for the cwd
|
|
26
|
+
* @param candidates - the raw installed source kinds (from
|
|
27
|
+
* {@link detectInstalledSources}); named in the ambiguous error
|
|
28
|
+
*/
|
|
29
|
+
export function resolveRefineSource(opts, detected, candidates = []) {
|
|
30
|
+
let kind;
|
|
31
|
+
if (opts.source !== undefined) {
|
|
32
|
+
if (!VALID_SOURCES.includes(opts.source)) {
|
|
33
|
+
return { error: `Invalid --source value: ${opts.source}. Use ${SOURCE_FORM}.` };
|
|
34
|
+
}
|
|
35
|
+
kind = opts.source;
|
|
36
|
+
}
|
|
37
|
+
else if (detected === 'ambiguous') {
|
|
38
|
+
return {
|
|
39
|
+
error: `Cannot determine refine source: multiple @skillit sources installed (found: ${candidates.join(', ')}).
|
|
40
|
+
Pass ${SOURCE_FORM} to choose one.`
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
else if (detected === 'none') {
|
|
44
|
+
return {
|
|
45
|
+
error: `Cannot determine refine source: no @skillit source package detected.
|
|
46
|
+
Pass ${SOURCE_FORM} to choose one.`
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
kind = detected;
|
|
51
|
+
}
|
|
52
|
+
if (kind === 'typedoc') {
|
|
53
|
+
return { error: 'typedoc refine not yet supported; use --source cli|mcp.' };
|
|
54
|
+
}
|
|
55
|
+
if (kind === 'mcp' && opts.mcp === undefined) {
|
|
56
|
+
return { error: 'The mcp source requires --mcp <path> (path to mcp.json or MCP config file).' };
|
|
57
|
+
}
|
|
58
|
+
return { kind };
|
|
59
|
+
}
|
|
60
|
+
/** The model backend to use; defaults to the API client. */
|
|
61
|
+
export function resolveModelClientKind(raw) {
|
|
62
|
+
return raw ?? 'api';
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* The body of the `refine` command action, extracted so it can be reused
|
|
66
|
+
* programmatically (e.g. by `skillit init`) without argv gymnastics. Sets
|
|
67
|
+
* `process.exitCode` and writes progress/errors to the console exactly as the
|
|
68
|
+
* CLI does.
|
|
69
|
+
*/
|
|
70
|
+
export async function runRefineCommand(opts) {
|
|
71
|
+
const cwd = process.cwd();
|
|
72
|
+
const maxIterations = parsePositiveInt(opts.maxIterations, '--max-iterations');
|
|
73
|
+
const itemsPerIteration = parsePositiveInt(opts.items, '--items');
|
|
74
|
+
const timeoutMs = opts.modelCliTimeout !== undefined
|
|
75
|
+
? parsePositiveInt(opts.modelCliTimeout, '--model-cli-timeout')
|
|
76
|
+
: undefined;
|
|
77
|
+
let model;
|
|
78
|
+
try {
|
|
79
|
+
model = createModelClient(resolveModelClientKind(opts.modelClient), timeoutMs !== undefined ? { timeoutMs } : {});
|
|
80
|
+
}
|
|
81
|
+
catch (error) {
|
|
82
|
+
console.error(error instanceof Error ? error.message : String(error));
|
|
83
|
+
process.exitCode = 1;
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
const candidates = await detectInstalledSources(cwd);
|
|
87
|
+
const detected = classifyRefineSources(candidates);
|
|
88
|
+
const resolution = resolveRefineSource(opts, detected, candidates);
|
|
89
|
+
if ('error' in resolution) {
|
|
90
|
+
console.error(resolution.error);
|
|
91
|
+
process.exitCode = 1;
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
let source;
|
|
95
|
+
let reportInPlace = false;
|
|
96
|
+
if (resolution.kind === 'cli') {
|
|
97
|
+
const program = await loadProgram({ program: opts.program, cwd });
|
|
98
|
+
const sourceGlob = opts.sourceGlob ?? join(cwd, '**', '*.ts');
|
|
99
|
+
source = new CliRefineSource({ program, sourceGlob, cwd });
|
|
100
|
+
reportInPlace = true;
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
// mcp source: --mcp guaranteed present by resolveRefineSource.
|
|
104
|
+
const mcpPath = opts.mcp;
|
|
105
|
+
const overlayPath = opts.overlay ?? join(cwd, '.skillit-overlay.json');
|
|
106
|
+
let mode;
|
|
107
|
+
if (opts.mode === 'build' || opts.mode === 'runtime') {
|
|
108
|
+
mode = opts.mode;
|
|
109
|
+
}
|
|
110
|
+
else if (opts.mode !== undefined) {
|
|
111
|
+
console.error(`Invalid --mode value: ${opts.mode}. Use 'build' or 'runtime'.`);
|
|
112
|
+
process.exitCode = 1;
|
|
113
|
+
return;
|
|
114
|
+
}
|
|
115
|
+
else {
|
|
116
|
+
const detectedMode = await detectRefineMode(cwd, mcpPath);
|
|
117
|
+
if (detectedMode === 'ambiguous') {
|
|
118
|
+
console.error(`Cannot determine refine mode.
|
|
119
|
+
Use --mode build (TypeScript MCP server you own)
|
|
120
|
+
--mode runtime (consuming project, any MCP server)`);
|
|
121
|
+
process.exitCode = 1;
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
mode = detectedMode;
|
|
125
|
+
}
|
|
126
|
+
if (mode === 'build') {
|
|
127
|
+
console.log('Refining in build mode (TypeScript MCP)');
|
|
128
|
+
}
|
|
129
|
+
else {
|
|
130
|
+
console.log('Refining in runtime mode (overlay)');
|
|
131
|
+
}
|
|
132
|
+
const entries = await readMcpConfigFile(mcpPath);
|
|
133
|
+
const entry = opts.server
|
|
134
|
+
? entries.find((e) => e.name === opts.server)
|
|
135
|
+
: entries.find((e) => !e.disabled);
|
|
136
|
+
if (!entry) {
|
|
137
|
+
const name = opts.server ? `"${opts.server}"` : 'any enabled server';
|
|
138
|
+
throw new Error(`Could not find ${name} in ${mcpPath}`);
|
|
139
|
+
}
|
|
140
|
+
if (mode === 'build') {
|
|
141
|
+
const sourceGlob = opts.sourceGlob ?? join(cwd, '**', '*.ts');
|
|
142
|
+
source = new TypeScriptMcpRefineSource({
|
|
143
|
+
transport: entry.transport,
|
|
144
|
+
sourceGlob
|
|
145
|
+
});
|
|
146
|
+
reportInPlace = true;
|
|
147
|
+
}
|
|
148
|
+
else {
|
|
149
|
+
source = new McpRefineSource({
|
|
150
|
+
overlayPath,
|
|
151
|
+
extract: () => extractMcpSkill({ transport: entry.transport })
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
const result = await runRefine(source, model, maxIterations, itemsPerIteration);
|
|
155
|
+
reportResult(result, { reportInPlace, overlayPath });
|
|
156
|
+
process.exitCode = result.passed ? 0 : 1;
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
const result = await runRefine(source, model, maxIterations, itemsPerIteration);
|
|
160
|
+
reportResult(result, { reportInPlace });
|
|
161
|
+
process.exitCode = result.passed ? 0 : 1;
|
|
162
|
+
}
|
|
163
|
+
export function buildRefineCommand() {
|
|
164
|
+
return new Command('refine')
|
|
165
|
+
.description('Autonomously improve a skill via the audit→draft→review loop')
|
|
166
|
+
.option('--source <kind>', 'cli | mcp | typedoc (auto-detected if omitted)')
|
|
167
|
+
.option('--program <file#export>', 'commander program entry (cli source)')
|
|
168
|
+
.option('--mcp <path>', 'path to mcp.json or MCP config file')
|
|
169
|
+
.option('--server <name>', 'server name within the config (defaults to first enabled)')
|
|
170
|
+
.option('--overlay <path>', 'path to overlay JSON file (runtime mode only)')
|
|
171
|
+
.option('--mode <mode>', 'refine mode: build or runtime (auto-detected if omitted)')
|
|
172
|
+
.option('--source-glob <glob>', 'glob pattern for TypeScript source files')
|
|
173
|
+
.option('--max-iterations <n>', 'iteration cap (default 5)', '5')
|
|
174
|
+
.option('--items <n>', 'work items per iteration (default 5)', '5')
|
|
175
|
+
.option('--model-client <kind>', 'model backend: api | claude | codex | copilot', 'api')
|
|
176
|
+
.option('--model-cli-timeout <ms>', 'per-call timeout for cli model backends (ms)')
|
|
177
|
+
.action((opts) => runRefineCommand(opts));
|
|
178
|
+
}
|
|
179
|
+
function runRefine(source, model, maxIterations, itemsPerIteration) {
|
|
180
|
+
return refineSkill({
|
|
181
|
+
source,
|
|
182
|
+
model,
|
|
183
|
+
maxIterations,
|
|
184
|
+
itemsPerIteration,
|
|
185
|
+
onIteration: (iter) => {
|
|
186
|
+
const { grade, total } = iter.estimate;
|
|
187
|
+
console.log(` Iteration ${iter.iteration}: grade ${grade} (${total}/120), ${iter.fixes.length} fix(es) applied`);
|
|
188
|
+
}
|
|
189
|
+
});
|
|
190
|
+
}
|
|
191
|
+
function reportResult(result, opts) {
|
|
192
|
+
console.log(`\nDone. Reason: ${result.stoppedReason}`);
|
|
193
|
+
console.log(`Final grade: ${result.finalEstimate.grade} (${result.finalEstimate.total}/120)`);
|
|
194
|
+
if (opts.reportInPlace) {
|
|
195
|
+
console.log(`Source files updated in place.`);
|
|
196
|
+
}
|
|
197
|
+
else if (opts.overlayPath && result.iterations.length > 0) {
|
|
198
|
+
console.log(`Overlay: ${opts.overlayPath}`);
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
//# sourceMappingURL=refine.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"refine.js","sourceRoot":"","sources":["../../src/commands/refine.ts"],"names":[],"mappings":"AAAA,yCAAyC;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EACL,eAAe,EACf,yBAAyB,EACzB,eAAe,EACf,iBAAiB,EAClB,M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KAAK,UAAU,IAAI,CAAC,KAAK,CAAC,MAAM,kBAAkB,CACrG,CAAC;QACJ,CAAC;KACF,CAAC,CAAC;AACL,CAAC;AAED,SAAS,YAAY,CACnB,MAA+C,EAC/C,IAAsD;IAEtD,OAAO,CAAC,GAAG,CAAC,mBAAmB,MAAM,CAAC,aAAa,EAAE,CAAC,CAAC;IACvD,OAAO,CAAC,GAAG,CAAC,gBAAgB,MAAM,CAAC,aAAa,CAAC,KAAK,KAAK,MAAM,CAAC,aAAa,CAAC,KAAK,OAAO,CAAC,CAAC;IAC9F,IAAI,IAAI,CAAC,aAAa,EAAE,CAAC;QACvB,OAAO,CAAC,GAAG,CAAC,gCAAgC,CAAC,CAAC;IAChD,CAAC;SAAM,IAAI,IAAI,CAAC,WAAW,IAAI,MAAM,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC5D,OAAO,CAAC,GAAG,CAAC,YAAY,IAAI,CAAC,WAAW,EAAE,CAAC,CAAC;IAC9C,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Detect refine mode from project context.
|
|
3
|
+
*
|
|
4
|
+
* @param cwd - directory to inspect for build/runtime signals
|
|
5
|
+
* @param mcpConfigPath - optional path to the --mcp config file; if its
|
|
6
|
+
* basename is a known runtime config filename, or its contents contain a
|
|
7
|
+
* top-level `mcpServers` key, it is treated as an additional runtime signal.
|
|
8
|
+
*/
|
|
9
|
+
export declare function detectRefineMode(cwd: string, mcpConfigPath?: string): Promise<'build' | 'runtime' | 'ambiguous'>;
|
|
10
|
+
//# sourceMappingURL=detect-mode.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"detect-mode.d.ts","sourceRoot":"","sources":["../src/detect-mode.ts"],"names":[],"mappings":"AAwEA;;;;;;;GAOG;AACH,wBAAsB,gBAAgB,CACpC,GAAG,EAAE,MAAM,EACX,aAAa,CAAC,EAAE,MAAM,GACrB,OAAO,CAAC,OAAO,GAAG,SAAS,GAAG,WAAW,CAAC,CAU5C"}
|