create-command-center 0.2.0 → 0.3.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/README.md +21 -1
- package/RELEASING.md +8 -4
- package/UPSTREAM.md +2 -0
- package/installer/build-parsers.mjs +21 -0
- package/installer/install.mjs +1 -1
- package/installer/template/README.md +2 -0
- package/installer/template/gitignore +1 -0
- package/package.json +32 -7
- package/skills/cc/SKILL.md +3 -1
- package/skills/cc/assets/config.md +4 -0
- package/skills/cc/references/jobs.md +2 -0
- package/skills/cc/references/registration.md +42 -18
- package/skills/cc/scripts/checks.mjs +109 -0
- package/skills/cc/scripts/errors.mjs +3 -0
- package/skills/cc/scripts/home.mjs +60 -0
- package/skills/cc/scripts/init.mjs +499 -0
- package/skills/cc/scripts/inspection.mjs +315 -0
- package/skills/cc/scripts/vendor/LICENSE.parsers.txt +70 -0
- package/skills/cc/scripts/vendor/parsers.mjs +9951 -0
package/README.md
CHANGED
|
@@ -6,7 +6,7 @@ The 26 upstream engineering skills and shared references are preserved from the
|
|
|
6
6
|
|
|
7
7
|
## Install a home repo
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
Version `0.3.0` adds the deterministic init helper described below. Install the latest published release in a new folder with Node.js 22 or newer and Git installed.
|
|
10
10
|
|
|
11
11
|
```sh
|
|
12
12
|
mkdir my-command-center
|
|
@@ -40,4 +40,24 @@ Start authorizes job branch commits, pushes, and PR creation after checks and re
|
|
|
40
40
|
|
|
41
41
|
No projects are enrolled automatically. Register the projects you want through `cc init`. Skills may include upstream bundled helpers for their specialized tasks, as documented in `UPSTREAM.md`.
|
|
42
42
|
|
|
43
|
+
## Deterministic init in 0.3.0
|
|
44
|
+
|
|
45
|
+
The `cc` skill calls its bundled Node helper to validate and normalize input, search saved configs, resolve a checkout, and prepare a version-2 inspection report. The agent reads the reported project files and proposes checks using project instructions first, then CI, then documented manifest scripts. Unknown essentials become setup gaps.
|
|
46
|
+
|
|
47
|
+
| Area | Helper behavior |
|
|
48
|
+
| --- | --- |
|
|
49
|
+
| Home discovery | Validates home markers, resolves canonical paths, and reports ambiguous choices |
|
|
50
|
+
| Project facts | Parses Node, Python, Go, and Rust declarations with source evidence and workspace membership |
|
|
51
|
+
| Freshness | Fingerprints inspected inputs and the home skill catalog, rejecting changed inputs before registration |
|
|
52
|
+
| Checks | Verifies supported script and native-command structures and records limits for custom commands |
|
|
53
|
+
| Instructions | Records each instruction file's governing directory and applicable ancestor order |
|
|
54
|
+
| Skills | Validates selected names against canonical home skill entries |
|
|
55
|
+
| Completion | Returns created, reused, or repaired with changed paths, effective settings, and setup gaps |
|
|
56
|
+
|
|
57
|
+
The helper then revalidates the checkout, saves config atomically, and adds its stable index link. Repeating init preserves chosen settings and repairs missing factual metadata or a missing index link. Collisions and clone failures stop registration with existing contents preserved. Preparation reports and process locks live in the ignored `.cc/` directory.
|
|
58
|
+
|
|
59
|
+
Generated facts, instruction scopes, and structural check results are saved in marked Markdown sections. Custom commands remain available with explicit validation limits. Project-specific meaning and actual runtime verification belong to the agent's engineering workflow.
|
|
60
|
+
|
|
61
|
+
The helper contract and structured details format are documented in [registration](skills/cc/references/registration.md). It is used by the skill through chat. Temporary helper reports and locks are separate from the versionable repo configs and job records.
|
|
62
|
+
|
|
43
63
|
Original Command Center code is licensed under [MIT](LICENSE). The upstream skills retain their [MIT license notice](LICENSE.agent-skills).
|
package/RELEASING.md
CHANGED
|
@@ -2,12 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
## Verify locally
|
|
4
4
|
|
|
5
|
-
Run `npm test` using Node.js 22 or newer and Git. The suite packs the package, installs
|
|
5
|
+
Run `npm ci`, then `npm test` using Node.js 22 or newer and Git. The suite packs the package, installs its tarball through npm offline, and executes the bundled helper from Codex and Claude copies. Fixture homes are temporary. Tests cover home resolution, evidence, workspaces, stale inputs, command/catalog validation, record preservation, and completion results.
|
|
6
|
+
|
|
7
|
+
The parser and workspace-glob dependencies are pinned as development dependencies and in `package-lock.json`. `npm run build:parsers` regenerates the checked-in helper bundle and notices. `npm pack` also runs this build through `prepack`. Generated homes use the bundle directly and need no dependency installation. Review bundle and notice changes alongside parser updates.
|
|
6
8
|
|
|
7
9
|
Create a distributable tarball with `npm pack`. To install it before publication, use its absolute path.
|
|
8
10
|
|
|
9
11
|
```sh
|
|
10
|
-
npm exec --yes --package=/absolute/path/create-command-center-0.
|
|
12
|
+
npm exec --yes --package=/absolute/path/create-command-center-0.3.0.tgz -- create-command-center ./my-home --agent both
|
|
11
13
|
```
|
|
12
14
|
|
|
13
15
|
Open a fresh Codex session and a fresh Claude Code session in the generated home. Confirm that `cc` and the engineering skills are listed. Exercise `cc init <repo-link>`, inspect its central config and ignored checkout, and repeat it to verify preservation. These live-agent discovery and registration checks complement the package tests.
|
|
@@ -16,10 +18,12 @@ Open a fresh Codex session and a fresh Claude Code session in the generated home
|
|
|
16
18
|
|
|
17
19
|
Review `npm pack --dry-run --json`. The package allowlist includes the installer, clean home templates, the shared skill library, references, upstream license, and provenance. User repo configs, job history, checkouts, and tests are excluded.
|
|
18
20
|
|
|
19
|
-
The
|
|
21
|
+
The npm package is `create-command-center`, owned by `rosstheboss94`. Confirm the npm account and package rights before publishing a new version. Original code uses the MIT license in `LICENSE`. The source repository is `https://github.com/rosstheboss94/command-center`. Preserve the upstream MIT notice in `LICENSE.agent-skills` separately.
|
|
20
22
|
|
|
21
23
|
Align package and plugin versions for a release. Refresh the bundled upstream tree and provenance only when intentionally changing its version. Review template changes, since the installer preserves conflicting files on repeat runs.
|
|
22
24
|
|
|
23
25
|
## Publish
|
|
24
26
|
|
|
25
|
-
|
|
27
|
+
Check `npm view create-command-center versions dist-tags --json` to confirm the current public versions before releasing. Each new version requires release authorization.
|
|
28
|
+
|
|
29
|
+
Authenticate with the intended npm account, verify its identity and package rights, and obtain release authorization. Then run `npm publish --access public`. Complete npm's publishing authentication and check the registry until the new version and dist-tag are visible. A staged placeholder or a successful command exit alone does not establish public availability. After publication, run `npx create-command-center@<version> . --agent both` from a fresh temporary folder and verify the generated home in fresh agent sessions.
|
package/UPSTREAM.md
CHANGED
|
@@ -9,3 +9,5 @@ The 26 upstream skill folders under `skills/` and shared checklists under `refer
|
|
|
9
9
|
Upstream skill folders include three bundled helpers used by their own guidance. These remain part of the upstream skills. Command Center's workflows and saved records are Markdown and require the host agent's existing tools.
|
|
10
10
|
|
|
11
11
|
To update, review a selected upstream commit, replace its skill folders and shared references together, preserve the local `cc` skill, update this provenance and license, and validate references and discovery before using the new version.
|
|
12
|
+
|
|
13
|
+
The local `cc` helper also bundles `smol-toml`, `yaml`, and `picomatch` for declarative project parsing and workspace expansion. Exact versions are pinned in the distribution's package files. Rebuild with `npm run build:parsers`. Their license notices ship beside the generated parser bundle in the skill's `scripts/vendor/` directory.
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { build } from 'esbuild';
|
|
2
|
+
import { readFile, mkdir, writeFile } from 'node:fs/promises';
|
|
3
|
+
import { fileURLToPath } from 'node:url';
|
|
4
|
+
import { join } from 'node:path';
|
|
5
|
+
|
|
6
|
+
const root = fileURLToPath(new URL('../', import.meta.url));
|
|
7
|
+
const destination = join(root, 'skills/cc/scripts/vendor');
|
|
8
|
+
await mkdir(destination, { recursive: true });
|
|
9
|
+
await build({
|
|
10
|
+
stdin: { contents: 'export { parse as parseToml } from "smol-toml"; export { parse as parseYaml } from "yaml"; export { default as makeMatcher } from "picomatch";', resolveDir: root },
|
|
11
|
+
bundle: true, platform: 'node', format: 'esm', target: 'node22',
|
|
12
|
+
outfile: join(destination, 'parsers.mjs'),
|
|
13
|
+
banner: { js: '// Generated by installer/build-parsers.mjs. See LICENSE.parsers.txt for notices.\nimport { createRequire } from "node:module"; const require = createRequire(import.meta.url);' },
|
|
14
|
+
});
|
|
15
|
+
let notices = 'Bundled data parsers. Rebuild with npm run build:parsers.\n';
|
|
16
|
+
for (const name of ['smol-toml', 'yaml', 'picomatch']) {
|
|
17
|
+
const directory = join(root, 'node_modules', name);
|
|
18
|
+
const metadata = JSON.parse(await readFile(join(directory, 'package.json'), 'utf8'));
|
|
19
|
+
notices += `\n${name} ${metadata.version}\n\n${await readFile(join(directory, 'LICENSE'), 'utf8')}\n`;
|
|
20
|
+
}
|
|
21
|
+
await writeFile(join(destination, 'LICENSE.parsers.txt'), notices.trimEnd() + '\n');
|
package/installer/install.mjs
CHANGED
|
@@ -95,7 +95,7 @@ export async function installHome(target, selection) {
|
|
|
95
95
|
if (!(await exists(join(destination, '.git')))) {
|
|
96
96
|
execFileSync('git', ['init', destination], { stdio: 'pipe' });
|
|
97
97
|
}
|
|
98
|
-
const marker = JSON.stringify({ kind: 'command-center-home', templateVersion: metadata.version, agents }, null, 2) + '\n';
|
|
98
|
+
const marker = JSON.stringify({ kind: 'command-center-home', schemaVersion: 1, templateVersion: metadata.version, agents }, null, 2) + '\n';
|
|
99
99
|
const temporary = join(destination, `${markerName}.${process.pid}.tmp`);
|
|
100
100
|
await writeFile(temporary, marker, { flag: 'wx' });
|
|
101
101
|
await rename(temporary, markerPath);
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
Open Codex or Claude Code in this folder and select the `cc` skill. Then request `cc init https://github.com/owner/project` in chat. The agent clones it into `projects/owner/project` and saves central settings under `repos/`.
|
|
4
4
|
|
|
5
|
+
Init uses the skill's bundled Node helper for home discovery, URL validation, identity matching, cloning, facts, scopes, freshness checks, and atomic config/index writes. It validates selected home skills and supported check structures. The agent chooses checks from project instructions first, then CI, then documented manifest scripts. Missing essentials and custom-command limits become setup gaps. Repeat init preserves settings and returns an exact created, reused, or repaired summary. Temporary reports and locks live in the ignored `.cc/` directory.
|
|
6
|
+
|
|
5
7
|
Use `cc repos`, `cc config <repo>`, `cc start <repo> <task>`, `cc status`, `cc resume <repo> <job>`, and `cc feedback <repo> <job> <text>` in chat. See `skills/cc/SKILL.md` for the workflow.
|
|
6
8
|
|
|
7
9
|
Starting a job authorizes job-branch commits, pushes, and a ready PR after checks and review. Skills honor existing approvals and require evidence for completion. Merge and deployment remain human decisions.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-command-center",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "Create a skills-based software factory home repo for Codex and Claude Code.",
|
|
5
5
|
"author": "rosstheboss94",
|
|
6
6
|
"repository": {
|
|
@@ -8,11 +8,36 @@
|
|
|
8
8
|
"url": "git+https://github.com/rosstheboss94/command-center.git"
|
|
9
9
|
},
|
|
10
10
|
"homepage": "https://github.com/rosstheboss94/command-center#readme",
|
|
11
|
-
"bugs": {
|
|
11
|
+
"bugs": {
|
|
12
|
+
"url": "https://github.com/rosstheboss94/command-center/issues"
|
|
13
|
+
},
|
|
12
14
|
"type": "module",
|
|
13
|
-
"engines": {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
"
|
|
17
|
-
|
|
15
|
+
"engines": {
|
|
16
|
+
"node": ">=22"
|
|
17
|
+
},
|
|
18
|
+
"bin": {
|
|
19
|
+
"create-command-center": "bin/create-command-center.mjs"
|
|
20
|
+
},
|
|
21
|
+
"files": [
|
|
22
|
+
"bin/",
|
|
23
|
+
"installer/",
|
|
24
|
+
"skills/",
|
|
25
|
+
"references/",
|
|
26
|
+
"LICENSE",
|
|
27
|
+
"LICENSE.agent-skills",
|
|
28
|
+
"UPSTREAM.md",
|
|
29
|
+
"RELEASING.md"
|
|
30
|
+
],
|
|
31
|
+
"scripts": {
|
|
32
|
+
"test": "node --test tests/*.test.mjs",
|
|
33
|
+
"build:parsers": "node installer/build-parsers.mjs",
|
|
34
|
+
"prepack": "npm run build:parsers"
|
|
35
|
+
},
|
|
36
|
+
"license": "MIT",
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"esbuild": "0.28.2",
|
|
39
|
+
"picomatch": "4.0.7",
|
|
40
|
+
"smol-toml": "1.9.1",
|
|
41
|
+
"yaml": "2.9.1"
|
|
42
|
+
}
|
|
18
43
|
}
|
package/skills/cc/SKILL.md
CHANGED
|
@@ -5,7 +5,7 @@ description: Initialize and operate a software factory home repo. Register proje
|
|
|
5
5
|
|
|
6
6
|
# Command Center
|
|
7
7
|
|
|
8
|
-
Interpret `cc` operations in chat using the host agent's normal tools.
|
|
8
|
+
Interpret `cc` operations in chat using the host agent's normal tools. For init, the bundled helper discovers and validates the home marker from its location and the invocation directory. Use the returned home path for subsequent operations. If it reports ambiguous or missing homes, resolve that choice before proceeding. For copied plugins or legacy unmarked homes, select an explicit valid home through `--home`. Product changes belong in the target checkout's Git history.
|
|
9
9
|
|
|
10
10
|
| Request | Action |
|
|
11
11
|
| --- | --- |
|
|
@@ -19,6 +19,8 @@ Interpret `cc` operations in chat using the host agent's normal tools. Locate th
|
|
|
19
19
|
|
|
20
20
|
Read [registration](references/registration.md) for init, repos, and config. Read [jobs](references/jobs.md) for start, status, resume, and feedback. A bare invocation describes operations without writing records.
|
|
21
21
|
|
|
22
|
+
For `cc init`, use the bundled Node helper at `scripts/init.mjs` for preparation and registration. Follow the helper contract in the registration reference. Inspect reported facts and scoped instructions, propose checks from project evidence, and select skills from its canonical home catalog. Use its completion status, effective settings, setup gaps, and validation limits when reporting the result.
|
|
23
|
+
|
|
22
24
|
Load relevant engineering skills from the home root's `skills/` on demand. Shared checklists live in the root `references/`. Read project instructions before operating there. User authorization takes precedence over skill defaults. Report conflicts that materially affect scope or checks.
|
|
23
25
|
|
|
24
26
|
Verify saved claims against files, commits, check results, and PR state. Resolve review findings and check failures before delivery. Preserve human decisions for merge and deployment.
|
|
@@ -13,6 +13,10 @@
|
|
|
13
13
|
|
|
14
14
|
List each required command, its working directory relative to the checkout, and its purpose. Record the source of the command. List unresolved setup items explicitly.
|
|
15
15
|
|
|
16
|
+
## Setup gaps
|
|
17
|
+
|
|
18
|
+
List unresolved essentials explicitly. The init helper records unavailable default-branch evidence and missing validation commands here.
|
|
19
|
+
|
|
16
20
|
## Engineering skills
|
|
17
21
|
|
|
18
22
|
Record project-specific additions or exclusions. Default to relevant shared lifecycle skills and specialists warranted by the work.
|
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
|
|
5
5
|
Resolve the registered checkout and confirm its Git identity. Report missing checkouts or mismatched remotes as blockers. Read central configuration and current project instructions. Preserve user edits. Use a dedicated branch or isolated worktree per job and record its exact path and base commit.
|
|
6
6
|
|
|
7
|
+
Use the config's generated Instruction scope data when present. Root rules apply across the checkout, while nested rules apply only within their directory. Legacy flat instruction lists retain each file's directory scope. Read the Check validation limits and setup gaps before treating the saved checks as ready for a job.
|
|
8
|
+
|
|
7
9
|
Create a unique UTC timestamp plus short random suffix under `jobs/<repo-id>/<job-id>/`. Save the exact request, a configuration snapshot as `config.md`, and `progress.md` based on [the progress template](../assets/progress.md). Freeze selected validation commands and delivery preferences. Configure skill output destinations in the job context to use this job's spec, plan, and task list. If project instructions require their own artifact locations, record those pointers and keep one authoritative task list.
|
|
8
10
|
|
|
9
11
|
Stages are `spec`, `plan`, `build`, `verify`, `review`, `deliver`, `ready`, `blocked`, and `rejected`. A blocked record includes the interrupted stage, actual reason, and input or recovery needed. Save evidence before marking stages complete. Preserve feedback, failures, and review rounds chronologically.
|
|
@@ -1,39 +1,63 @@
|
|
|
1
1
|
# Registration and central configuration
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Run the bundled helper with Node.js 22 or newer and Git available. It discovers the home from canonical ancestors of the invocation directory and helper location. Explicit `--home` selects a home directly. Multiple candidates require a choice. Plugin caches are excluded from automatic discovery. Use the original valid home explicitly for a copied plugin. Existing bootstrap markers are accepted. Unmarked homes need a valid marker before discovery can use them.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## `cc init` procedure
|
|
6
6
|
|
|
7
|
-
`
|
|
7
|
+
1. Call `node <skill>/scripts/init.mjs prepare --cwd <invocation-directory> --source <repo-link-or-path>` with separate, quoted arguments. Use `--home` when selecting a specific home. Omit `--source` when the user omitted it. At the home root, an omitted source produces `SOURCE_REQUIRED`.
|
|
8
|
+
2. Read the returned home, version-2 report, structured facts, catalog, and inspection paths. Instruction scopes identify root and nested governing directories. Read only the instructions applicable to the work's directory, in ancestor order. A template instruction file governs its template directory. Keep the preparation report path.
|
|
9
|
+
3. Choose checks using explicit project instructions first, then CI commands, then documented manifest scripts. Record each command's working directory and exact source file. List unresolved conflicts and missing essentials as setup gaps. Registration does not execute checks.
|
|
10
|
+
4. Save a UTF-8 details JSON file in the home `.cc/` directory using the shape below. Populate purpose, relevant skill names, check proposals, and gaps from inspection. Existing chosen settings survive repeats.
|
|
11
|
+
5. Call `node <skill>/scripts/init.mjs register --home <returned-home> --report <report-path> --details <details-file>`. Read its exit code and JSON response. Report its `status`, identifiers, exact `changes`, effective `settings`, `setupGaps`, and `validationLimits` after success. Preparation changes and registration changes describe their respective operations.
|
|
8
12
|
|
|
9
|
-
|
|
13
|
+
```json
|
|
14
|
+
{
|
|
15
|
+
"purpose": "Project purpose supported by its documentation",
|
|
16
|
+
"checks": [
|
|
17
|
+
{ "command": "npm test", "workingDirectory": ".", "source": "AGENTS.md" }
|
|
18
|
+
],
|
|
19
|
+
"skills": ["test-driven-development"],
|
|
20
|
+
"setupGaps": []
|
|
21
|
+
}
|
|
22
|
+
```
|
|
10
23
|
|
|
11
|
-
|
|
24
|
+
Every check source must be in the inspection report. Working directories are relative to the checkout and must stay inside it. Supply empty arrays and explicit gaps when no checks or specialist skills are known. A missing purpose, missing checks, or unavailable default branch automatically creates a setup gap for a new record. The agent resolves command meaning and conflicts from project evidence. The helper validates structure and saves the result.
|
|
12
25
|
|
|
13
|
-
|
|
26
|
+
## Facts and validation
|
|
14
27
|
|
|
15
|
-
|
|
28
|
+
The helper reads data formats without executing project code. Structured facts cover Node package manifests and npm/pnpm/Yarn/Bun evidence, Python pyproject/Pipfile/requirements and uv/Poetry/Pipenv evidence, Go module/workspace declarations, and Rust package/workspace manifests. Workspace patterns are expanded against discovered projects with exclusions and repository boundaries. Each fact carries source evidence. Lockfiles marked `presence_only` establish their tool's presence without claiming their dependency contents were parsed. Unsupported or malformed manifests produce diagnostics and setup gaps.
|
|
16
29
|
|
|
17
|
-
|
|
30
|
+
Supported check structures include explicit Node script runners (`npm run`, `npm run-script`, `pnpm run`, `yarn run`, `bun run`), declared lifecycle aliases, Python declared entry points through `uv run`, `poetry run`, or `pipenv run`, basic `go test`, and Cargo check commands with the documented flags in the helper. Package scripts and Cargo package selections must exist in the relevant project/workspace. The selected manager must agree with confirmed declaration/lockfile evidence.
|
|
18
31
|
|
|
19
|
-
|
|
32
|
+
Successful structural resolution returns `verified_structure`. Custom commands, unsupported flags, external Python tools, and compound shell expressions return `unresolved_structure` with explicit limits and setup gaps. This status covers the command's declared structure. Check adequacy and runtime success require the job's actual verification stage.
|
|
20
33
|
|
|
21
|
-
|
|
34
|
+
Select skills from `catalog.skills`. Names must resolve to one valid canonical `home/skills/` entry. Discovery copies and user/project libraries do not add catalog entries. Missing or ambiguous selected skills produce `SKILL_INVALID`. Unselected malformed entries are returned as catalog diagnostics.
|
|
22
35
|
|
|
23
|
-
|
|
36
|
+
## Freshness and saved records
|
|
24
37
|
|
|
25
|
-
|
|
38
|
+
Preparation fingerprints instruction files, manifests, lockfiles, CI, documentation, and home skill entry points. Registration compares content and membership, then rederives facts from the current files. `INSPECTION_STALE` identifies changed paths and requires another preparation and agent inspection. Version-1 reports also require preparation again. Resolve parse, catalog, or command validation errors before retrying registration.
|
|
26
39
|
|
|
27
|
-
|
|
40
|
+
Configs retain editable Markdown settings and user notes. Generated Project facts, Instruction scope, and Check validation sections have `cc-init` ownership markers. The helper refreshes those sections and missing factual metadata while preserving existing chosen settings. Use `cc config` to amend those settings. Do not edit the preparation report to override facts.
|
|
28
41
|
|
|
29
|
-
|
|
42
|
+
Completion status is `created` for a new config, `repaired` for a changed existing config/index, and `reused` when both are unchanged. The compatibility `reused` boolean indicates that a config previously existed. Repeat-run results reflect saved settings and identify legacy validation prose that needs review.
|
|
30
43
|
|
|
31
|
-
|
|
44
|
+
## Fixed helper behavior
|
|
45
|
+
|
|
46
|
+
- Existing local paths take precedence over `owner/repo` shorthand. Remote inputs accept GitHub HTTPS root links, `git@github.com:owner/repo[.git]`, `ssh://git@github.com/owner/repo[.git]`, and `owner/repo`. Terminal `.git` and trailing slashes are removed for identity. Extra path segments, queries, fragments, other hosts, traversal, and credential-bearing URLs are rejected. The SSH user `git` is permitted.
|
|
47
|
+
- GitHub identities are lowercase `github.com/owner/repo`. New remote IDs are lowercase `owner--repo`, with `projects/<owner>/<repo>` checkouts. HTTPS links and shorthand clone through canonical HTTPS. SSH inputs clone through canonical SCP-style SSH. Git receives the argument array `clone`, `--`, URL, destination. Existing Git authentication applies.
|
|
48
|
+
- All central configs are searched before cloning. Missing identity metadata is derived from supported remote fields. Duplicate identities, malformed configs, and ID collisions stop the operation. Existing IDs, paths, and chosen settings are retained. Missing recorded checkouts require recovery.
|
|
49
|
+
- An existing destination must be its own Git top-level with a matching origin. A conflicting directory or origin is preserved and reported. Linked paths inside home cannot redirect a clone or registry write outside it.
|
|
50
|
+
- The helper ensures `/projects/` and `/.cc/` ignore rules are effective before cloning. Failed clones remain unregistered. Inspect any partial destination before retrying. Cleanup and relocation require an explicit recovery decision.
|
|
51
|
+
- Inspection resolves the primary checkout and common Git directory, origin, current branch, and default-branch evidence from `refs/remotes/origin/HEAD`. It lists project instructions, manifests, lockfiles, CI, and documentation in sorted order, skipping dependency and generated directories. It reads filenames and Git metadata. The agent reads the selected files to derive project meaning.
|
|
52
|
+
- New local registrations use lowercase checkout basenames with spaces replaced by hyphens. Local-only and non-GitHub-origin repositories match by their canonical primary checkout. Earlier local IDs for a GitHub identity are retained.
|
|
53
|
+
- Preparation reports live in `.cc/init/`. Registration rechecks checkout identity and scans configs again under an exclusive `.cc/init.lock`. It atomically writes config first, then adds one stable relative index link. Repeats repair missing factual metadata and missing links, preserving saved settings and index organization. An interrupted index write is repaired by repeating registration.
|
|
54
|
+
|
|
55
|
+
Both helper operations return JSON with `ok: true` on success. Errors return nonzero with `ok: false` and a redacted error. Stop at a helper refusal. A lock records its PID and start time. Inspect the owner and any Git child processes before recovering a stale lock. Never remove a lock owned by a live operation.
|
|
32
56
|
|
|
33
57
|
## Repos and config
|
|
34
58
|
|
|
35
|
-
`cc repos` reads the index and configs
|
|
59
|
+
`cc repos` reads the index and configs and reports paths and setup gaps. Inspection writes nothing. Above about 20 repos, group index links by purpose while retaining stable IDs.
|
|
36
60
|
|
|
37
|
-
`cc config <repo>` displays settings. A requested change updates only those settings.
|
|
61
|
+
`cc config <repo>` displays settings. A requested change updates only those settings. Commands resolve relative to the checkout, and skills relative to home. Changes affect future jobs. Existing jobs retain their saved config.
|
|
38
62
|
|
|
39
|
-
Central configuration owns factory settings. Project instructions apply
|
|
63
|
+
Central configuration owns factory settings. Project instructions apply in their repository. Inspect and report disagreements with central commands before claiming verification. Ask only for material choices that project evidence cannot settle.
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { posix } from 'node:path';
|
|
2
|
+
import { applicableInstructions } from './inspection.mjs';
|
|
3
|
+
import { failure } from './errors.mjs';
|
|
4
|
+
|
|
5
|
+
function projectAt(facts, cwd, ecosystem) {
|
|
6
|
+
return facts.projects.filter(item => item.ecosystem === ecosystem && (item.path === '.' || item.path === cwd || cwd.startsWith(`${item.path}/`)))
|
|
7
|
+
.sort((a, b) => b.path.length - a.path.length)[0];
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
function invalid(message) { throw failure('CHECK_INVALID', message); }
|
|
11
|
+
|
|
12
|
+
export function validateSkills(names, catalog) {
|
|
13
|
+
for (const name of names) {
|
|
14
|
+
const matches = catalog.skills.filter(skill => skill.name === name);
|
|
15
|
+
if (matches.length !== 1 || !matches[0].valid) throw failure('SKILL_INVALID', `Skill ${name} does not resolve to one valid canonical home entry.`, { paths: matches.map(skill => skill.path) });
|
|
16
|
+
}
|
|
17
|
+
return names.map(name => catalog.skills.find(skill => skill.name === name));
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function validateManager(project, selected) {
|
|
21
|
+
if (project.manager.status === 'conflicting') invalid(`Package-manager evidence conflicts for ${project.path}.`);
|
|
22
|
+
if (project.manager.name && project.manager.name !== selected) invalid(`Selected manager ${selected} contradicts ${project.manager.name} for ${project.path}.`);
|
|
23
|
+
return project.manager.name ? [] : ['Package-manager selection has no confirmed declaration or lockfile evidence.'];
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function validateChecks(checks, facts, scopes) {
|
|
27
|
+
return checks.map(check => {
|
|
28
|
+
const cwd = posix.normalize(check.workingDirectory.replaceAll('\\', '/'));
|
|
29
|
+
const result = { command: check.command, workingDirectory: check.workingDirectory, source: check.source,
|
|
30
|
+
applicableInstructions: applicableInstructions(scopes, cwd).map(item => item.path), validationStatus: 'unresolved_structure', limits: [], evidence: [] };
|
|
31
|
+
if (/\r|\n|\0/.test(check.command)) invalid('Check command must be a single line.');
|
|
32
|
+
if (/[;&|<>`$]|\$\(/.test(check.command)) {
|
|
33
|
+
result.limits.push('Custom or compound command requires project-specific interpretation.');
|
|
34
|
+
return result;
|
|
35
|
+
}
|
|
36
|
+
// Recognize a deliberately small command grammar. Shell expansion remains opaque.
|
|
37
|
+
const tokens = check.command.trim().split(/\s+/);
|
|
38
|
+
const runner = tokens[0];
|
|
39
|
+
for (let index = 1; index < tokens.length; index++) {
|
|
40
|
+
const match = /^(--prefix|--cwd|--dir|-C|--manifest-path)(?:=(.*))?$/.exec(tokens[index]);
|
|
41
|
+
if (match) {
|
|
42
|
+
const target = match[2] ?? tokens[index + 1];
|
|
43
|
+
if (!target) invalid('Check path override is missing its target.');
|
|
44
|
+
const path = posix.normalize(posix.join(cwd, target.replaceAll('\\', '/')));
|
|
45
|
+
if (posix.isAbsolute(target) || /^[a-z]:/i.test(target) || path === '..' || path.startsWith('../')) invalid('Check target escapes the checkout.');
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
const node = projectAt(facts, cwd, 'node');
|
|
49
|
+
if (['npm', 'pnpm', 'yarn', 'bun'].includes(runner)) {
|
|
50
|
+
if (node) result.limits.push(...validateManager(node, runner));
|
|
51
|
+
let script;
|
|
52
|
+
let argsStart;
|
|
53
|
+
if (tokens[1] === 'run' || runner === 'npm' && tokens[1] === 'run-script') { script = tokens[2]; argsStart = 3; }
|
|
54
|
+
else if (['test', 'start', 'stop', 'restart'].includes(tokens[1]) && runner !== 'bun') { script = tokens[1]; argsStart = 2; }
|
|
55
|
+
if (!script || !/^[a-z0-9:._-]+$/i.test(script) || tokens.length > argsStart && tokens[argsStart] !== '--') {
|
|
56
|
+
result.limits.push('Package-manager command is outside the supported script-invocation grammar.'); return result;
|
|
57
|
+
}
|
|
58
|
+
if (!node || node.path !== cwd) invalid('Package script must run from the directory containing its package.json.');
|
|
59
|
+
if (!Object.hasOwn(node.scripts, script)) invalid(`Package script ${script} does not exist in ${node.manifest}.`);
|
|
60
|
+
result.evidence.push(node.scripts[script].evidence, ...node.manager.evidence);
|
|
61
|
+
} else if (runner === 'go' && tokens[1] === 'test') {
|
|
62
|
+
const project = projectAt(facts, cwd, 'go');
|
|
63
|
+
if (!project) invalid('go test requires a discovered Go module or workspace.');
|
|
64
|
+
if (tokens.slice(2).some(token => !['.', './...', '-race', '-v', '-cover', '-short'].includes(token) && !/^-count=\d+$/.test(token))) {
|
|
65
|
+
result.limits.push('Go flags or targets require project-specific interpretation.'); return result;
|
|
66
|
+
}
|
|
67
|
+
result.evidence.push(project.evidence.path);
|
|
68
|
+
} else if (runner === 'cargo' && ['test', 'check', 'clippy', 'fmt'].includes(tokens[1])) {
|
|
69
|
+
const project = projectAt(facts, cwd, 'rust');
|
|
70
|
+
if (!project) invalid('Cargo checks require a discovered Cargo project or workspace.');
|
|
71
|
+
const workspace = facts.projects.filter(item => item.ecosystem === 'rust' && item.workspace?.status === 'resolved' && item.workspace.members.includes(project.path)).sort((a, b) => b.path.length - a.path.length)[0] || project;
|
|
72
|
+
for (let index = 2; index < tokens.length; index++) {
|
|
73
|
+
if (tokens[index] !== '-p' && tokens[index] !== '--package') continue;
|
|
74
|
+
const name = tokens[index + 1];
|
|
75
|
+
if (!facts.projects.some(item => item.ecosystem === 'rust' && item.name === name && (item.path === workspace.path || workspace.workspace?.members.includes(item.path)))) invalid('Cargo package is outside the discovered workspace.');
|
|
76
|
+
}
|
|
77
|
+
if (tokens.some(token => /^--(?:manifest-path|config|target-dir)/.test(token))) {
|
|
78
|
+
result.limits.push('Cargo path/config overrides require project-specific interpretation.'); return result;
|
|
79
|
+
}
|
|
80
|
+
const supported = new Set(['--workspace', '--all-targets', '--all-features', '--no-default-features', '--locked', '--offline', '--quiet', '--verbose', '-q', '-v']);
|
|
81
|
+
const options = tokens.slice(2).filter((token, index, list) => token !== '-p' && token !== '--package' && list[index - 1] !== '-p' && list[index - 1] !== '--package');
|
|
82
|
+
if (options.some(token => !supported.has(token))) {
|
|
83
|
+
result.limits.push('Cargo flags or targets require project-specific interpretation.'); return result;
|
|
84
|
+
}
|
|
85
|
+
result.evidence.push(project.evidence.path, ...(workspace.workspace?.evidence || []));
|
|
86
|
+
} else {
|
|
87
|
+
let python = projectAt(facts, cwd, 'python');
|
|
88
|
+
let script;
|
|
89
|
+
if (['uv', 'poetry', 'pipenv'].includes(runner) && tokens[1] === 'run') script = tokens[2];
|
|
90
|
+
if (python && script) {
|
|
91
|
+
const candidates = facts.projects.filter(item => item.ecosystem === 'python' && item.path === python.path && Object.hasOwn(item.scripts, script));
|
|
92
|
+
if (new Set(candidates.map(item => item.scripts[script].command)).size > 1) invalid('Python entry point has conflicting declarations.');
|
|
93
|
+
python = candidates[0] || python;
|
|
94
|
+
result.limits.push(...validateManager(python, runner));
|
|
95
|
+
}
|
|
96
|
+
if (python && script && Object.hasOwn(python.scripts, script) && tokens.length === 3) {
|
|
97
|
+
result.evidence.push(python.scripts[script].evidence, ...python.manager.evidence);
|
|
98
|
+
} else {
|
|
99
|
+
result.limits.push('Custom command or external Python tool cannot be resolved from declared entry points.'); return result;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
result.validationStatus = result.limits.length ? 'unresolved_structure' : 'verified_structure';
|
|
103
|
+
return result;
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export function checkGaps(checks) {
|
|
108
|
+
return checks.filter(check => check.validationStatus !== 'verified_structure').map(check => `Check ${check.command} requires confirmation. ${check.limits.join(' ')}`);
|
|
109
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { lstat, readFile, realpath } from 'node:fs/promises';
|
|
2
|
+
import { resolve, dirname, join } from 'node:path';
|
|
3
|
+
import { fileURLToPath } from 'node:url';
|
|
4
|
+
import { failure } from './errors.mjs';
|
|
5
|
+
|
|
6
|
+
async function info(path) {
|
|
7
|
+
try { return await lstat(path); }
|
|
8
|
+
catch (error) { if (error.code === 'ENOENT') return null; throw error; }
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export async function validateHome(path) {
|
|
12
|
+
try {
|
|
13
|
+
const home = await realpath(resolve(path));
|
|
14
|
+
const markerPath = join(home, '.command-center.json');
|
|
15
|
+
const markerInfo = await info(markerPath);
|
|
16
|
+
if (!markerInfo?.isFile() || markerInfo.isSymbolicLink()) throw new Error('Home marker is missing or linked.');
|
|
17
|
+
const marker = JSON.parse(await readFile(markerPath, 'utf8'));
|
|
18
|
+
if (marker.kind !== 'command-center-home' || (marker.schemaVersion !== undefined && marker.schemaVersion !== 1) ||
|
|
19
|
+
typeof marker.templateVersion !== 'string' || !/^\d+\.\d+\.\d+(?:[-+][a-z0-9.-]+)?$/i.test(marker.templateVersion) ||
|
|
20
|
+
!Array.isArray(marker.agents) || marker.agents.some(agent => !['codex', 'claude'].includes(agent)) ||
|
|
21
|
+
new Set(marker.agents).size !== marker.agents.length) throw new Error('Unsupported home marker.');
|
|
22
|
+
for (const name of ['repos', 'skills', 'skills/cc']) {
|
|
23
|
+
const entry = await info(join(home, name));
|
|
24
|
+
if (!entry?.isDirectory() || entry.isSymbolicLink()) throw new Error(`Required home directory is missing or linked: ${name}`);
|
|
25
|
+
}
|
|
26
|
+
for (const name of ['AGENTS.md', 'skills/cc/SKILL.md']) {
|
|
27
|
+
const entry = await info(join(home, name));
|
|
28
|
+
if (!entry?.isFile() || entry.isSymbolicLink()) throw new Error(`Required home file is missing or linked: ${name}`);
|
|
29
|
+
}
|
|
30
|
+
return { home, marker };
|
|
31
|
+
} catch (error) {
|
|
32
|
+
throw failure('HOME_INVALID', `Invalid home at ${resolve(path)}. ${error.message}`);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function pluginCache(path) {
|
|
37
|
+
return /\/(?:\.codex|\.claude)\/plugins\/cache(?:\/|$)/i.test(path.replaceAll('\\', '/'));
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export async function discoverHome({ home, cwd = process.cwd(), helperDirectory = dirname(fileURLToPath(import.meta.url)) } = {}) {
|
|
41
|
+
if (home) return { ...await validateHome(home), selectedBy: 'explicit' };
|
|
42
|
+
const candidates = new Map();
|
|
43
|
+
for (const start of [cwd, helperDirectory]) {
|
|
44
|
+
let current = await realpath(resolve(start));
|
|
45
|
+
if (pluginCache(current)) continue;
|
|
46
|
+
while (true) {
|
|
47
|
+
if (await info(join(current, '.command-center.json'))) {
|
|
48
|
+
const candidate = await validateHome(current);
|
|
49
|
+
const key = process.platform === 'win32' ? candidate.home.toLowerCase() : candidate.home;
|
|
50
|
+
candidates.set(key, candidate);
|
|
51
|
+
}
|
|
52
|
+
const parent = dirname(current);
|
|
53
|
+
if (parent === current) break;
|
|
54
|
+
current = parent;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
if (!candidates.size) throw failure('HOME_NOT_FOUND', 'No home marker found. Supply --home with a valid Command Center home.');
|
|
58
|
+
if (candidates.size > 1) throw failure('HOME_AMBIGUOUS', 'Multiple homes found. Select one with --home.', { candidates: [...candidates.values()].map(item => item.home).sort() });
|
|
59
|
+
return { ...candidates.values().next().value, selectedBy: 'discovered' };
|
|
60
|
+
}
|