@nseng-ai/areg 0.1.1
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/package.json +29 -0
- package/src/cli.ts +109 -0
- package/src/context.ts +59 -0
- package/src/fake-gateways.ts +1009 -0
- package/src/gateways/command-constants.ts +1 -0
- package/src/gateways/errors.ts +5 -0
- package/src/gateways/fs-utils.ts +26 -0
- package/src/gateways/github-gateway.ts +111 -0
- package/src/gateways/host-gateway.ts +35 -0
- package/src/gateways/mutation-policy.ts +94 -0
- package/src/gateways/npx-skills-gateway.ts +53 -0
- package/src/gateways/project-fs.ts +320 -0
- package/src/gateways/project-gateway.ts +801 -0
- package/src/gateways/prompt-gateway.ts +21 -0
- package/src/gateways/skill-kind-classification.ts +39 -0
- package/src/gateways/skillx-workspace-gateway.ts +220 -0
- package/src/gateways.ts +361 -0
- package/src/index.ts +48 -0
- package/src/operations/check.ts +559 -0
- package/src/operations/doctor-skills-report.ts +109 -0
- package/src/operations/doctor-skills-severity.ts +9 -0
- package/src/operations/doctor-skills.ts +471 -0
- package/src/operations/file-state.ts +77 -0
- package/src/operations/frontmatter.ts +151 -0
- package/src/operations/init.ts +548 -0
- package/src/operations/lockfile.ts +107 -0
- package/src/operations/managed-markdown-block.ts +47 -0
- package/src/operations/pi-replacement.ts +33 -0
- package/src/operations/pi-settings.ts +60 -0
- package/src/operations/project-agents.ts +115 -0
- package/src/operations/project-inspection.ts +165 -0
- package/src/operations/project-mutations.ts +383 -0
- package/src/operations/project-resolution.ts +53 -0
- package/src/operations/skill-find.ts +295 -0
- package/src/operations/skill-kind-apply-plan.ts +531 -0
- package/src/operations/skill-kind-frontmatter.ts +55 -0
- package/src/operations/skill-kind-inference.ts +391 -0
- package/src/operations/skill-kind.ts +525 -0
- package/src/operations/skill-mirror-conventions.ts +126 -0
- package/src/operations/skillx.ts +305 -0
- package/src/operations/toml-section.ts +53 -0
- package/src/operations/update-skills.ts +325 -0
- package/src/real-gateways.ts +6 -0
- package/src/skill-lookup.ts +254 -0
- package/src/sort.ts +7 -0
package/package.json
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@nseng-ai/areg",
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"files": [
|
|
6
|
+
"src"
|
|
7
|
+
],
|
|
8
|
+
"engines": {
|
|
9
|
+
"node": ">=24.12.0",
|
|
10
|
+
"pnpm": ">=11.8.0"
|
|
11
|
+
},
|
|
12
|
+
"publishConfig": {
|
|
13
|
+
"access": "public"
|
|
14
|
+
},
|
|
15
|
+
"bin": {
|
|
16
|
+
"areg": "src/cli.ts"
|
|
17
|
+
},
|
|
18
|
+
"exports": {
|
|
19
|
+
".": "./src/index.ts"
|
|
20
|
+
},
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"@nseng-ai/capability-kit": "0.1.1",
|
|
23
|
+
"@nseng-ai/clinkr": "0.1.1",
|
|
24
|
+
"@nseng-ai/command-backed-skill-registry": "0.1.1",
|
|
25
|
+
"@nseng-ai/foundation": "0.1.1",
|
|
26
|
+
"smol-toml": "^1.6.1",
|
|
27
|
+
"zod": "^4.4.3"
|
|
28
|
+
}
|
|
29
|
+
}
|
package/src/cli.ts
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
import { ClinkrGroup } from "@nseng-ai/clinkr";
|
|
4
|
+
import { defineCli, type CliEntrypointDeps } from "@nseng-ai/foundation/cli-runtime";
|
|
5
|
+
|
|
6
|
+
import { createRealAregContext, type AregCliContext } from "./context.ts";
|
|
7
|
+
import {
|
|
8
|
+
doctorSkillsRequestSchema,
|
|
9
|
+
doctorSkillsResultSchema,
|
|
10
|
+
runDoctorSkills,
|
|
11
|
+
} from "./operations/doctor-skills.ts";
|
|
12
|
+
import { renderDoctorSkills } from "./operations/doctor-skills-report.ts";
|
|
13
|
+
import {
|
|
14
|
+
checkRequestSchema,
|
|
15
|
+
checkResultSchema,
|
|
16
|
+
renderCheck,
|
|
17
|
+
runCheck,
|
|
18
|
+
} from "./operations/check.ts";
|
|
19
|
+
import { initRequestSchema, initResultSchema, renderInit, runInit } from "./operations/init.ts";
|
|
20
|
+
import { buildSkillGroup } from "./operations/skill-kind.ts";
|
|
21
|
+
import { buildSkillxGroup } from "./operations/skillx.ts";
|
|
22
|
+
import {
|
|
23
|
+
renderUpdateSkills,
|
|
24
|
+
runUpdateSkills,
|
|
25
|
+
updateSkillsRequestSchema,
|
|
26
|
+
updateSkillsResultSchema,
|
|
27
|
+
} from "./operations/update-skills.ts";
|
|
28
|
+
|
|
29
|
+
export interface CliDeps extends Pick<CliEntrypointDeps, "cwd" | "env" | "stdout" | "stderr"> {
|
|
30
|
+
context?: AregCliContext;
|
|
31
|
+
interaction?: AregCliContext["interaction"];
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const entry = defineCli<AregCliContext, CliDeps, undefined>({
|
|
35
|
+
metaUrl: import.meta.url,
|
|
36
|
+
runtime: "typescript",
|
|
37
|
+
description: "Manage ns agent registry projects.",
|
|
38
|
+
prepareRun: ({ deps, cwd, env }) => {
|
|
39
|
+
const context = deps.context ?? createRealAregContext({ cwd, env });
|
|
40
|
+
const runContext: AregCliContext = {
|
|
41
|
+
...context,
|
|
42
|
+
cwd,
|
|
43
|
+
env: deps.env ?? context.env,
|
|
44
|
+
interaction: deps.interaction ?? context.interaction,
|
|
45
|
+
};
|
|
46
|
+
return { type: "run", context: runContext, buildState: undefined };
|
|
47
|
+
},
|
|
48
|
+
configureCli: ({ root }) => {
|
|
49
|
+
root.command({
|
|
50
|
+
name: "init",
|
|
51
|
+
description: "Initialize an existing Git project for areg skill workflows.",
|
|
52
|
+
schema: initRequestSchema,
|
|
53
|
+
positionals: { target: { position: 0 } },
|
|
54
|
+
options: { yes: { short: "-y" } },
|
|
55
|
+
resultSchema: initResultSchema,
|
|
56
|
+
handler: runInit,
|
|
57
|
+
renderHuman: renderInit,
|
|
58
|
+
});
|
|
59
|
+
root.command({
|
|
60
|
+
name: "check",
|
|
61
|
+
description: "Check that skills follow areg conventions.",
|
|
62
|
+
schema: checkRequestSchema,
|
|
63
|
+
resultSchema: checkResultSchema,
|
|
64
|
+
handler: runCheck,
|
|
65
|
+
renderHuman: renderCheck,
|
|
66
|
+
});
|
|
67
|
+
root.command({
|
|
68
|
+
name: "update-skills",
|
|
69
|
+
description: "Refresh GitHub-sourced skills recorded in skills-lock.json.",
|
|
70
|
+
schema: updateSkillsRequestSchema,
|
|
71
|
+
resultSchema: updateSkillsResultSchema,
|
|
72
|
+
handler: runUpdateSkills,
|
|
73
|
+
renderHuman: renderUpdateSkills,
|
|
74
|
+
});
|
|
75
|
+
const doctorGroup = new ClinkrGroup<AregCliContext>({
|
|
76
|
+
name: "doctor",
|
|
77
|
+
description: "Diagnose areg project drift.",
|
|
78
|
+
});
|
|
79
|
+
doctorGroup.command({
|
|
80
|
+
name: "skills",
|
|
81
|
+
description: "Diagnose skill registry, Pi inventory, and replacement-command drift.",
|
|
82
|
+
schema: doctorSkillsRequestSchema,
|
|
83
|
+
resultSchema: doctorSkillsResultSchema,
|
|
84
|
+
handler: runDoctorSkills,
|
|
85
|
+
renderHuman: renderDoctorSkills,
|
|
86
|
+
});
|
|
87
|
+
root.group(doctorGroup);
|
|
88
|
+
root.group(buildSkillGroup());
|
|
89
|
+
const execGroup = new ClinkrGroup<AregCliContext>({
|
|
90
|
+
name: "exec",
|
|
91
|
+
description: "Commands for use by skills (not interactive users).",
|
|
92
|
+
isHidden: true,
|
|
93
|
+
});
|
|
94
|
+
execGroup.group(buildSkillxGroup());
|
|
95
|
+
root.group(execGroup);
|
|
96
|
+
},
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
export const VERSION = entry.version;
|
|
100
|
+
|
|
101
|
+
export function buildCli(): ClinkrGroup<AregCliContext> {
|
|
102
|
+
return entry.buildCli(undefined);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export async function runCli(args: readonly string[], deps: CliDeps = {}): Promise<number> {
|
|
106
|
+
return await entry.run(args, deps);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
await entry.runIfMain({ isImportMetaMain: import.meta.main });
|
package/src/context.ts
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { resolveClinkrInteraction, type ClinkrInteraction } from "@nseng-ai/clinkr";
|
|
2
|
+
import { NodeCommandExecApi } from "@nseng-ai/foundation/exec";
|
|
3
|
+
import { RealGitGateway } from "@nseng-ai/capability-kit/git";
|
|
4
|
+
import type { GitGateway } from "@nseng-ai/capability-kit/git";
|
|
5
|
+
import { readStdinLine } from "@nseng-ai/foundation/cli-runtime";
|
|
6
|
+
|
|
7
|
+
import type {
|
|
8
|
+
AregGithubGateway,
|
|
9
|
+
AregHostGateway,
|
|
10
|
+
AregNpxSkillsGateway,
|
|
11
|
+
AregProjectGateway,
|
|
12
|
+
AregPromptGateway,
|
|
13
|
+
AregSkillxWorkspaceGateway,
|
|
14
|
+
} from "./gateways.ts";
|
|
15
|
+
import {
|
|
16
|
+
RealAregGithubGateway,
|
|
17
|
+
RealAregHostGateway,
|
|
18
|
+
RealAregNpxSkillsGateway,
|
|
19
|
+
RealAregProjectGateway,
|
|
20
|
+
RealAregPromptGateway,
|
|
21
|
+
RealAregSkillxWorkspaceGateway,
|
|
22
|
+
} from "./real-gateways.ts";
|
|
23
|
+
|
|
24
|
+
export interface AregCliContext {
|
|
25
|
+
host: AregHostGateway;
|
|
26
|
+
github: AregGithubGateway;
|
|
27
|
+
skillxWorkspace: AregSkillxWorkspaceGateway;
|
|
28
|
+
project: AregProjectGateway;
|
|
29
|
+
git: GitGateway;
|
|
30
|
+
npxSkills: AregNpxSkillsGateway;
|
|
31
|
+
prompt: AregPromptGateway;
|
|
32
|
+
interaction: ClinkrInteraction;
|
|
33
|
+
cwd: string;
|
|
34
|
+
env: NodeJS.ProcessEnv;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export function createRealAregContext(
|
|
38
|
+
options: { cwd?: string; env?: NodeJS.ProcessEnv } = {},
|
|
39
|
+
): AregCliContext {
|
|
40
|
+
const cwd = options.cwd ?? process.cwd();
|
|
41
|
+
const env = options.env ?? process.env;
|
|
42
|
+
const npxSkills = new RealAregNpxSkillsGateway();
|
|
43
|
+
const git = new RealGitGateway(new NodeCommandExecApi());
|
|
44
|
+
return {
|
|
45
|
+
host: new RealAregHostGateway(),
|
|
46
|
+
github: new RealAregGithubGateway(),
|
|
47
|
+
skillxWorkspace: new RealAregSkillxWorkspaceGateway({ npxSkills }),
|
|
48
|
+
project: new RealAregProjectGateway({ git }),
|
|
49
|
+
git,
|
|
50
|
+
npxSkills,
|
|
51
|
+
prompt: new RealAregPromptGateway(),
|
|
52
|
+
interaction: resolveClinkrInteraction({
|
|
53
|
+
stdin: readStdinLine,
|
|
54
|
+
stderr: (text) => process.stderr.write(text),
|
|
55
|
+
}),
|
|
56
|
+
cwd,
|
|
57
|
+
env,
|
|
58
|
+
};
|
|
59
|
+
}
|