@nichollasf/ai-kit 1.0.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.
Files changed (39) hide show
  1. package/.agents/archetypes/implementer-senior.md +46 -0
  2. package/.agents/archetypes/implementer.md +46 -0
  3. package/.agents/archetypes/orchestrator.md +54 -0
  4. package/.agents/archetypes/planner.md +54 -0
  5. package/.agents/archetypes/quick.md +46 -0
  6. package/.agents/archetypes/researcher.md +46 -0
  7. package/.agents/archetypes/reviewer.md +46 -0
  8. package/.agents/catalog/catalog-v2.schema.json +1641 -0
  9. package/.agents/catalog/personal.json +370 -0
  10. package/.agents/skills/ai-kit-model-calibration/SKILL.md +57 -0
  11. package/.agents/skills/ai-kit-model-calibration/assets/scorecard.md +61 -0
  12. package/.agents/skills/ai-kit-model-calibration/references/rubric.md +41 -0
  13. package/.agents/skills/ai-kit-task-routing/SKILL.md +44 -0
  14. package/.agents/skills/ai-kit-task-routing/references/handoff.md +29 -0
  15. package/LICENSE +21 -0
  16. package/README.md +151 -0
  17. package/dist/catalog.d.ts +99 -0
  18. package/dist/catalog.js +590 -0
  19. package/dist/catalog.js.map +1 -0
  20. package/dist/cli.d.ts +10 -0
  21. package/dist/cli.js +201 -0
  22. package/dist/cli.js.map +1 -0
  23. package/dist/diagnostics.d.ts +2 -0
  24. package/dist/diagnostics.js +301 -0
  25. package/dist/diagnostics.js.map +1 -0
  26. package/dist/installer.d.ts +18 -0
  27. package/dist/installer.js +303 -0
  28. package/dist/installer.js.map +1 -0
  29. package/dist/legacy.d.ts +7 -0
  30. package/dist/legacy.js +69 -0
  31. package/dist/legacy.js.map +1 -0
  32. package/dist/manifest.d.ts +50 -0
  33. package/dist/manifest.js +223 -0
  34. package/dist/manifest.js.map +1 -0
  35. package/dist/transaction.d.ts +10 -0
  36. package/dist/transaction.js +187 -0
  37. package/dist/transaction.js.map +1 -0
  38. package/docs/architecture.md +61 -0
  39. package/package.json +62 -0
package/README.md ADDED
@@ -0,0 +1,151 @@
1
+ # @nichollasf/ai-kit
2
+
3
+ A personal archetype catalog for **Claude Code, Codex and OpenCode**, installed into a project with `npx`. Select a complete team or individual roles, choose the harnesses, and install relative file links or copies. Node.js 20+; zero runtime dependencies.
4
+
5
+ The CLI distributes packaged content. It does not run agents, install harnesses, configure credentials, or install globally. Harness installation and account access are needed to execute the profiles, not to copy the catalog.
6
+
7
+ ## Install
8
+
9
+ From an existing project, open the wizard:
10
+
11
+ ```sh
12
+ npx @nichollasf/ai-kit
13
+ ```
14
+
15
+ The wizard defaults to the complete seven-role team. Individual selection leaves orchestration disabled. Noninteractive installation requires explicit harness selection and defaults to the full team:
16
+
17
+ ```sh
18
+ npx @nichollasf/ai-kit add --harnesses codex,claude-code,opencode --yes
19
+ npx @nichollasf/ai-kit add --harnesses codex --archetypes quick,reviewer --primary quick --method copy --yes
20
+ npx @nichollasf/ai-kit add --harnesses opencode --team --target "../my project" --dry-run
21
+ ```
22
+
23
+ For an incomplete team, `--primary <selected-role>` chooses the standalone main role without enabling delegation. Change it transactionally with `update --primary reviewer`; the other selected roles stay installed. All harnesses default to the first selected role when no primary is specified. Claude/OpenCode also support native manual agent selection.
24
+
25
+ `init` remains an alias for `add`. `--method symlink` is the default; every discovery link points relatively to a known regular file inside the installation. Unsupported symlinks abort with a recommendation to use `--method copy`; the method never changes silently.
26
+
27
+ ## Commands
28
+
29
+ | Command | Behavior |
30
+ | ------------- | -------------------------------------------------------------------------------------- |
31
+ | `add`, `init` | Install into an existing project; an identical installation is a no-op. |
32
+ | `list` | Print all archetypes, pinned model bindings, effort mappings and presets. |
33
+ | `update` | Replace intact owned artifacts; keep selection unless explicitly replaced. |
34
+ | `check` | Report structural integrity, local availability and behavioral limitations separately. |
35
+ | `uninstall` | Remove only intact manifest-owned artifacts and the manifest. |
36
+
37
+ All project commands accept `--target`. Mutating commands accept `--dry-run` with zero writes, including no temporary files. `check --dry-run` checks structure but skips harness processes, returning readiness unverified. `--yes` bypasses the wizard for explicit selections. There is no `--force` or global mode.
38
+
39
+ ```sh
40
+ npx @nichollasf/ai-kit list
41
+ npx @nichollasf/ai-kit update --dry-run
42
+ npx @nichollasf/ai-kit update --harnesses codex,opencode --method copy
43
+ npx @nichollasf/ai-kit check
44
+ npx @nichollasf/ai-kit check --route claude
45
+ npx @nichollasf/ai-kit uninstall --dry-run
46
+ ```
47
+
48
+ `--route claude` checks the explicit OpenCode alternative; it does not rewrite defaults. Exit codes: `0` success; `2` CLI usage; `3` safety/preflight rejection; `4` check failed or readiness unverified; `1` unexpected failure. Installer errors never authorize overwriting local changes.
49
+
50
+ ## Archetypes and presets
51
+
52
+ | Archetype | Responsibility | Codex / default OpenCode | Claude Code / alternative OpenCode |
53
+ | ----------------------------------------- | --------------------------------------------------------------------------------------------------- | ------------------------ | ---------------------------------- |
54
+ | Planner | Architecture and executable tasks; no implementation or delegation | `gpt-6-astra` | `claude-fable-5-1` |
55
+ | Orchestrator | Dispatch approved tasks, track dependencies and synthesize; no product implementation or replanning | `gpt-5.6-sol` | `claude-opus-5` |
56
+ | Senior-Implementer (`implementer-senior`) | Complex, risky or coupled implementation; no delegation | `gpt-5.6-sol` | `claude-opus-5` |
57
+ | Implementer | Bounded implementation with defined approach and acceptance | `gpt-5.6-terra` | `claude-sonnet-5` |
58
+ | Quick | Narrow, reversible changes; escalate high-risk work | `gpt-5.6-luna` | `claude-haiku-4-5-20251001` |
59
+ | Researcher | Evidence and uncertainty; no architecture decisions or implementation | `gpt-5.6-luna` | `claude-haiku-4-5-20251001` |
60
+ | Reviewer | Independent review and validation assessment; no edits to reviewed work | `gpt-5.6-sol` | `claude-opus-5` |
61
+
62
+ Only Orchestrator delegates. No worker coordinates another worker. Four workers may run simultaneously only with independent scopes. Non-trivial changes require Reviewer in a fresh context; changing model provider is optional.
63
+
64
+ GPT effort by low / medium / high task complexity:
65
+
66
+ | Role | Effort mapping |
67
+ | ------------------------------------------ | -------------------------- |
68
+ | Planner | medium / high / xhigh |
69
+ | Orchestrator, Senior-Implementer, Reviewer | xhigh / xhigh / xhigh |
70
+ | Implementer, Researcher | low / medium / high |
71
+ | Quick | low / medium / unavailable |
72
+
73
+ Claude Planner uses medium/high/xhigh, Opus roles use xhigh, and Implementer uses low/medium/high. Haiku effort is explicitly unsupported; adapters emit no effort parameter. IDs are explicit and versioned; neither installation nor routing resolves `latest`.
74
+
75
+ Each binding has stable profiles containing archetype, model ID and effort, such as `implementer-gpt-5.6-terra-high`. OpenCode also exposes `implementer` for the default GPT route and `implementer-claude` for the explicit Claude route. Unavailable unselected Claude models do not block GPT; selecting an unavailable route produces a diagnostic instead of fallback.
76
+
77
+ ## Layout and discovery
78
+
79
+ ```text
80
+ .agents/
81
+ archetypes/ Selected model-free role contracts
82
+ catalog/personal.json Versioned bindings and presets
83
+ catalog/catalog-v2.schema.json
84
+ generated/selection.json Selection and orchestration state
85
+ generated/<harness>/ Materialized profiles and main configuration
86
+ skills/ Own shared skills
87
+ .ai-kit-manifest.json Exact artifact ownership, schema v3
88
+ plans/ User-owned; never installed or removed
89
+ evals/ User-owned; never installed or removed
90
+ .codex/config.toml Main configuration link/copy
91
+ .codex/agents/*.toml Codex role links/copies
92
+ .claude/settings.json Main Orchestrator selection when team is complete
93
+ .claude/agents/*.md Adapted Claude links/copies
94
+ .claude/skills/... Per-file skill links/copies
95
+ .opencode/agents/*.md Native OpenCode profile links/copies
96
+ opencode.json OpenCode main configuration link/copy
97
+ ```
98
+
99
+ Codex and OpenCode discover shared skills in `.agents/skills/`; Claude receives per-file links or copies. Canonical `.agents/archetypes` frontmatter is a deliberately small OpenCode-compatible subset: exactly a JSON-quoted `description` scalar and `mode: primary|subagent`, UTF-8/LF, no duplicate keys or other YAML features. Rendered Claude and OpenCode frontmatter are separate adaptations.
100
+
101
+ Codex must trust the project before its project configuration loads. Claude's complete-team settings select `orchestrator` as the main agent. OpenCode selects `orchestrator` as its primary agent; choose a `*-claude` profile explicitly for the alternative route.
102
+
103
+ ## Plans and actual enforcement
104
+
105
+ A Planner task records ID, Objective, Role, Binding/profile, Effort, Dependencies, Write Scope, Acceptance Criteria and Validation Commands. Approval uses `Approved-Plan-SHA256` over the UTF-8/LF plan body before the marker, including its final LF. The marker is recorded after actual user approval; a hash is not evidence of consent. Orchestrator rejects missing fields, changed digests, invalid dependencies and stale evidence. Architecture or plan changes return to Planner and require renewed approval.
106
+
107
+ Roles without a cryptographic hash tool must receive fresh verification from a trusted host or user tool and compare the current plan with the verified snapshot. They must never invent a digest. If this evidence is missing, they request it before dispatch. For example, outside the agent, use Node's SHA-256 on the exact LF plan body before adding the marker; retain that verified body with the approval.
108
+
109
+ Start planning in a standalone Planner session: `claude --agent planner --effort high --setting-sources project` or `opencode --agent planner`. Codex can select it with `ai-kit update --archetypes planner --primary planner`, then restore the approved-plan team with `ai-kit update --team`. These commands use the existing installed harness selection. Orchestrator does not invent a plan to bypass missing approval.
110
+
111
+ Handoffs preserve `Objective; Evidence; Work Or Findings; Validation; Risks; Escalation`.
112
+
113
+ | Harness | Enforced configuration | Behavioral limits |
114
+ | ----------- | ----------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
115
+ | Codex | Configured workers disable delegation; Planner, Researcher and Reviewer have read-only sandboxes; four-thread setting | Main Orchestrator uses workspace-write so implementing workers can inherit it. Its no-product-edit rule and restriction to registered profiles remain instructions. Planner returns plan text for the user to save. |
116
+ | Claude Code | Worker `Agent`/`Task` tools denied; main `Agent(...)` allowlist; read-only roles lack write/shell tools; depth/concurrency settings | Planner's plan-directory scope is behavioral; concurrency has harness exceptions. The allowlist applies only in the main context. |
117
+ | OpenCode | Task allowlist on primary Orchestrator, worker task denial, read-only/edit restrictions and depth limit | Four-worker cap, task-scoped product edits, approval freshness and mechanical routing depend on compliance. |
118
+
119
+ Prompts do not provide security isolation. Personal settings, CLI overrides, account model access and harness versions can affect effective behavior. `check` separates those availability/capability checks from file integrity; missing authentication never prevents installation but prevents declaring the environment ready. No model generation is used for diagnostics or integration tests.
120
+
121
+ ## Updates and migration
122
+
123
+ Ownership is by exact file path, never directory or filename prefix. Preexisting conflicting configurations abort before mutation; the installer does not merge personal or shared configuration files. Unrelated agents, files inside skill directories, empty user directories, plans, evaluations and personal Kilo configuration remain untouched.
124
+
125
+ `update` migrates intact v1/v2 installations only with explicit new harness selection:
126
+
127
+ ```sh
128
+ npx @nichollasf/ai-kit update --harnesses codex,claude-code,opencode --dry-run
129
+ npx @nichollasf/ai-kit update --harnesses codex,claude-code,opencode
130
+ ```
131
+
132
+ Only historical files recorded in a complete validated manifest are retired, including Kilo agents. Modified or missing owned files abort the whole operation. Legacy `.agents/catalog/local.json` stays unmanaged and preserved; incompatible overrides block migration and new installation. Empty legacy overlay metadata is accepted. Overlays never alter the new presets silently.
133
+
134
+ Customize model IDs in the **source repository's** `personal.json`, review and package that change, then run `update` in target projects. Do not edit installed owned files: their checksum mismatch deliberately blocks update/uninstall. Previous v3 aliases are derived from the verified installed catalog so a source model update can safely retire renamed profiles. A renamed role or changed layout requires an explicit migration design.
135
+
136
+ Changes stage on the same filesystem, back up each file or link, roll back on failure, and apply the manifest last. A lock prevents cooperating concurrent installers. If rollback cannot safely restore data, backups and the lock remain with a diagnostic path. After a process crash, inspect `.agents/.ai-kit-lock` and transaction backups before retrying; crash recovery is manual.
137
+
138
+ ## Development
139
+
140
+ ```sh
141
+ npm ci
142
+ npm run check
143
+ npm run test:integration
144
+ npm pack --dry-run --json
145
+ ```
146
+
147
+ Tests cover the catalog, wizard, ownership, links/copies, migrations, rollback, zero-write dry-run and installation from an actual tarball through offline `npx`. Codex 0.154.0 has no validated narrow API for project trust and every effective role setting. Normal `check` uses redacted diagnostics and conservatively returns `4` for that unresolved layer; it does not fetch raw personal configuration. Native integration establishes those configuration properties only in isolated test stores. Claude runtime discovery uses project-only settings, so use `claude --setting-sources project` for that checked scope. OpenCode Planner paths are relative to its Git worktree; nested project targets may require returning plan text in the handoff when native plan-directory writes are denied.
148
+
149
+ Native integration checks use isolated temporary configuration stores and no model calls. Unavailable CLIs are explicitly skipped; see the test report. Validated locally with Codex 0.154.0, Claude Code 2.1.265 and OpenCode 1.18.30.
150
+
151
+ The public package allowlist excludes legacy catalog/prompts, credentials, overlays, plans, evaluations and third-party skills. Version 1.0.0 introduces the breaking layout and manifest transition described in [the architecture decision](docs/architecture.md). Release validation includes an exact package inventory and a redacted secret scan of the public source, Git history and packed artifact.
@@ -0,0 +1,99 @@
1
+ import { type Asset } from "./manifest.js";
2
+ export declare const ROLE_NAMES: readonly ["planner", "orchestrator", "implementer-senior", "implementer", "quick", "researcher", "reviewer"];
3
+ export type RoleName = (typeof ROLE_NAMES)[number];
4
+ export declare const HARNESS_NAMES: readonly ["codex", "claude-code", "opencode"];
5
+ export type HarnessName = (typeof HARNESS_NAMES)[number];
6
+ export type Method = "symlink" | "copy";
7
+ export interface Selection {
8
+ harnesses: HarnessName[];
9
+ archetypes: RoleName[];
10
+ method: Method;
11
+ primary?: RoleName;
12
+ }
13
+ export declare const COMPLEXITIES: readonly ["low", "medium", "high"];
14
+ export type Complexity = (typeof COMPLEXITIES)[number];
15
+ export declare const EFFORTS: readonly ["low", "medium", "high", "xhigh"];
16
+ export type Effort = (typeof EFFORTS)[number];
17
+ export declare const ROUTES: readonly ["gpt", "claude"];
18
+ export type Route = (typeof ROUTES)[number];
19
+ export declare const CATALOG_SCHEMA_PATH = ".agents/catalog/catalog-v2.schema.json";
20
+ export declare const BASE_CATALOG_PATH = ".agents/catalog/personal.json";
21
+ export declare const LOCAL_CATALOG_PATH = ".agents/catalog/local.json";
22
+ export declare const PROMPT_PATHS: string[];
23
+ export declare const CATALOG_PATHS: string[];
24
+ export declare const SKILL_PATHS: readonly [".agents/skills/ai-kit-model-calibration/SKILL.md", ".agents/skills/ai-kit-model-calibration/assets/scorecard.md", ".agents/skills/ai-kit-model-calibration/references/rubric.md", ".agents/skills/ai-kit-task-routing/SKILL.md", ".agents/skills/ai-kit-task-routing/references/handoff.md"];
25
+ export declare const REQUIRED_TASK_FIELDS: readonly ["ID", "Objective", "Role", "Binding", "Effort", "Dependencies", "Write Scope", "Acceptance Criteria", "Validation Commands"];
26
+ export declare const HANDOFF_FIELDS: readonly ["Objective", "Evidence", "Work Or Findings", "Validation", "Risks", "Escalation"];
27
+ export interface ModelDefinition {
28
+ family: Route;
29
+ id: string;
30
+ harnesses: Partial<Record<HarnessName, string>>;
31
+ }
32
+ export interface Binding {
33
+ archetype: RoleName;
34
+ route: Route;
35
+ model: string;
36
+ effortSupport: "supported" | "unsupported";
37
+ supportedEfforts: Effort[];
38
+ effort: Partial<Record<Complexity, Effort>>;
39
+ }
40
+ export interface RolePolicy {
41
+ archetype: string;
42
+ capabilities: {
43
+ read: true;
44
+ write: {
45
+ enabled: boolean;
46
+ scopes: string[];
47
+ };
48
+ delegate: boolean;
49
+ review: boolean;
50
+ };
51
+ }
52
+ export interface Catalog {
53
+ schemaVersion: 2;
54
+ profile: "personal";
55
+ maxConcurrency: number;
56
+ roles: Record<RoleName, RolePolicy>;
57
+ models: Record<string, ModelDefinition>;
58
+ bindings: Record<string, Binding>;
59
+ presets: {
60
+ codex: Record<RoleName, string>;
61
+ "claude-code": Record<RoleName, string>;
62
+ opencode: {
63
+ defaultRoute: "gpt";
64
+ routes: ["gpt", "claude"];
65
+ };
66
+ };
67
+ taskContract: {
68
+ requiredFields: string[];
69
+ approvalMarker: "Approved-Plan-SHA256";
70
+ digestAlgorithm: "sha256";
71
+ };
72
+ reviewGate: {
73
+ requiredFor: "non-trivial";
74
+ role: "reviewer";
75
+ independent: true;
76
+ };
77
+ handoff: string[];
78
+ }
79
+ export interface LoadedCatalog {
80
+ catalog: Catalog;
81
+ baseChecksum: string;
82
+ catalogAssets: Asset[];
83
+ prompts: Record<RoleName, string>;
84
+ descriptions: Record<RoleName, string>;
85
+ skillAssets: Asset[];
86
+ }
87
+ export declare function normalizeSelection(value: Selection): Selection;
88
+ export declare function orchestrationEnabled(selection: Selection): boolean;
89
+ export declare function validateCatalog(value: unknown): Catalog;
90
+ /** Own frontmatter is deliberately limited to two scalar keys; it is not a YAML parser. */
91
+ export declare function parseArchetype(content: string, role: RoleName): {
92
+ description: string;
93
+ body: string;
94
+ };
95
+ export declare function loadCatalog(packageRoot: string, _target?: string): Promise<LoadedCatalog>;
96
+ export declare function getBinding(catalog: Catalog, role: RoleName, harness: HarnessName, route?: Route): Binding;
97
+ export declare function defaultEffort(binding: Binding): Effort | undefined;
98
+ export declare function profileName(catalog: Catalog, role: RoleName, binding: Binding, effort?: Effort): string;
99
+ export declare function materialize(loaded: LoadedCatalog, value: Selection): Asset[];