projectops 4.104.5 → 4.104.7
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 +1 -1
- package/bin/projectops.js +4 -4
- package/package.json +1 -1
- package/src/cli/args.js +43 -43
- package/src/cli/errors.js +8 -8
- package/src/cli/help.js +4 -4
- package/src/commands/doctor.js +39 -39
- package/src/commands/full.js +29 -29
- package/src/commands/interactive.js +86 -86
- package/src/commands/issues.js +5 -5
- package/src/commands/skills.js +13 -13
- package/src/commands/version.js +8 -8
- package/src/commands/workflows.js +19 -19
- package/src/context.js +24 -24
- package/src/core/agent-guide.js +5 -5
- package/src/core/assets.js +11 -11
- package/src/core/baseline.js +24 -24
- package/src/core/branch-sub.js +23 -23
- package/src/core/breaking-check.js +21 -21
- package/src/core/breaking.js +6 -6
- package/src/core/ci-minutes-sub.js +13 -13
- package/src/core/constants.js +17 -17
- package/src/core/copy/coderabbit.js +10 -10
- package/src/core/copy/gitignore.js +9 -9
- package/src/core/copy/readme.js +7 -7
- package/src/core/copy/simple.js +35 -35
- package/src/core/copy/util.js +9 -9
- package/src/core/copy/workflows.js +99 -99
- package/src/core/detect-fs.js +21 -21
- package/src/core/detect.js +12 -12
- package/src/core/development-branch.js +11 -11
- package/src/core/exclusions.js +12 -12
- package/src/core/fsutil.js +9 -9
- package/src/core/git-branch.js +11 -11
- package/src/core/ide/adapter.js +23 -23
- package/src/core/ide/adapters/claude.js +12 -12
- package/src/core/ide/adapters/codex.js +4 -4
- package/src/core/ide/adapters/copilot.js +12 -12
- package/src/core/ide/adapters/cursor.js +7 -7
- package/src/core/ide/adapters/gemini.js +5 -5
- package/src/core/ide/adapters/pi-common.js +12 -12
- package/src/core/ide/adapters/pi-harness.js +7 -7
- package/src/core/ide/adapters/pi.js +3 -3
- package/src/core/ide/home-skills.js +6 -6
- package/src/core/ide/legacy.js +8 -8
- package/src/core/ide/registry.js +6 -6
- package/src/core/ide/runner.js +15 -15
- package/src/core/ide/skills-copy.js +34 -34
- package/src/core/ide/stable-entry.js +11 -11
- package/src/core/ide/util.js +4 -4
- package/src/core/incoming.js +13 -13
- package/src/core/label-style.js +12 -12
- package/src/core/migration-guide.js +19 -19
- package/src/core/migrations/index.js +16 -16
- package/src/core/migrations/registry.js +39 -39
- package/src/core/migrations/rules/legacy-dirs.js +6 -6
- package/src/core/migrations/rules/obsolete-workflows.js +4 -4
- package/src/core/migrations/rules/root-files.js +3 -3
- package/src/core/migrations/rules/settings-extractors.js +8 -8
- package/src/core/options-ask.js +104 -104
- package/src/core/options-schema.js +23 -23
- package/src/core/orphan-workflows.js +14 -14
- package/src/core/paths-resolve.js +54 -54
- package/src/core/paths.js +2 -2
- package/src/core/placeholder-triggers.js +10 -10
- package/src/core/repo-language.js +10 -10
- package/src/core/resolve-options.js +30 -30
- package/src/core/run-trace.js +54 -54
- package/src/core/store-locales-hint.js +13 -13
- package/src/core/verify.js +27 -27
- package/src/core/version-yml.js +115 -115
- package/src/core/wizard-env.js +42 -42
- package/src/core/wizard-labels.js +31 -31
- package/src/core/workflow-groups.js +14 -14
- package/src/i18n/core.en.js +1 -1
- package/src/i18n/doctor.en.js +1 -1
- package/src/i18n/ide.en.js +1 -1
- package/src/i18n/migrate.en.js +1 -1
- package/src/i18n/options.en.js +1 -1
- package/src/index.js +60 -60
- package/src/ui/ansi.js +5 -5
- package/src/ui/env-plan.js +44 -44
- package/src/ui/prompts.js +21 -21
- package/src/ui/readline-engine.js +38 -38
- package/src/ui/skills-prompts.js +4 -4
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// PI
|
|
1
|
+
// Shared PI paths and status logic (shared by the pi and pi-harness adapters).
|
|
2
2
|
import { join } from "node:path";
|
|
3
3
|
import { existsSync, readFileSync, writeFileSync, rmSync } from "node:fs";
|
|
4
4
|
import { t } from "../../../i18n/index.js";
|
|
@@ -6,15 +6,15 @@ import { TEMPLATE_REPO_OWNER, TEMPLATE_REPO_WEB_URL } from "../../paths.js";
|
|
|
6
6
|
|
|
7
7
|
export const PI_PACKAGE_URL = TEMPLATE_REPO_WEB_URL;
|
|
8
8
|
|
|
9
|
-
// 'pi list'
|
|
9
|
+
// Installed if 'pi list' output shows our repo. (Both old repo names and the project name are accepted)
|
|
10
10
|
export function piInstalled(io) {
|
|
11
11
|
if (!io.which("pi")) return false;
|
|
12
|
-
const r = io.run("pi", ["list"]); // pi
|
|
12
|
+
const r = io.run("pi", ["list"]); // pi sends some output to stderr → check both
|
|
13
13
|
const out = (r.stdout || "") + (r.stderr || "");
|
|
14
14
|
return /SUH-DEVOPS-TEMPLATE|projectops/i.test(out);
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
// pi
|
|
17
|
+
// pi clone path (where the harness loader lives). Backward compatible with the old path from before the repo rename.
|
|
18
18
|
export function piCloneDir(io) {
|
|
19
19
|
const base = join(io.home(), ".pi/agent/git/github.com", TEMPLATE_REPO_OWNER);
|
|
20
20
|
const newDir = join(base, "projectops");
|
|
@@ -25,7 +25,7 @@ export function piCloneDir(io) {
|
|
|
25
25
|
export function harnessLoaderPath(io) { return join(piCloneDir(io), "harness/harness-loader.ts"); }
|
|
26
26
|
export function piSettingsPath(io) { return join(io.home(), ".pi/agent/settings.json"); }
|
|
27
27
|
|
|
28
|
-
//
|
|
28
|
+
// Is the loader registered in the extensions array of settings.json?
|
|
29
29
|
export function harnessEnabled(io) {
|
|
30
30
|
const settings = piSettingsPath(io), loader = harnessLoaderPath(io);
|
|
31
31
|
if (!existsSync(settings)) return false;
|
|
@@ -35,13 +35,13 @@ export function harnessEnabled(io) {
|
|
|
35
35
|
} catch { return false; }
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
//
|
|
38
|
+
// Add the loader to extensions (no duplicates). {ok, reason}.
|
|
39
39
|
export function harnessAdd(io) {
|
|
40
40
|
const settings = piSettingsPath(io), loader = harnessLoaderPath(io);
|
|
41
41
|
if (!existsSync(settings)) return { ok: false, reason: "no-settings" };
|
|
42
42
|
if (!existsSync(loader)) return { ok: false, reason: "no-loader" };
|
|
43
43
|
let s;
|
|
44
|
-
//
|
|
44
|
+
// Do not overwrite on a parse failure (writing {} would wipe every user settings key)
|
|
45
45
|
try { s = JSON.parse(readFileSync(settings, "utf8")); } catch { return { ok: false, reason: "invalid-settings" }; }
|
|
46
46
|
if (s === null || typeof s !== "object" || Array.isArray(s)) return { ok: false, reason: "invalid-settings" };
|
|
47
47
|
const exts = (Array.isArray(s.extensions) ? s.extensions : []).filter(Boolean);
|
|
@@ -51,7 +51,7 @@ export function harnessAdd(io) {
|
|
|
51
51
|
return { ok: true };
|
|
52
52
|
}
|
|
53
53
|
|
|
54
|
-
//
|
|
54
|
+
// Remove the loader from extensions. {ok}.
|
|
55
55
|
export function harnessRemove(io) {
|
|
56
56
|
const settings = piSettingsPath(io), loader = harnessLoaderPath(io);
|
|
57
57
|
if (!existsSync(settings)) return { ok: true };
|
|
@@ -64,8 +64,8 @@ export function harnessRemove(io) {
|
|
|
64
64
|
return { ok: true };
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
-
//
|
|
68
|
-
//
|
|
67
|
+
// When old and new clones coexist, remove the old SUH-DEVOPS-TEMPLATE clone + its loader path from settings.json.
|
|
68
|
+
// Clean up only when both exist (if only the old one exists, leave it until pi install makes the new one). Failure is harmless.
|
|
69
69
|
export function migratePiLegacy(io) {
|
|
70
70
|
const base = join(io.home(), ".pi/agent/git/github.com", TEMPLATE_REPO_OWNER);
|
|
71
71
|
const oldDir = join(base, "SUH-DEVOPS-TEMPLATE");
|
|
@@ -80,7 +80,7 @@ export function migratePiLegacy(io) {
|
|
|
80
80
|
s.extensions = s.extensions.filter((e) => e && e !== oldLoader);
|
|
81
81
|
writeFileSync(settings, JSON.stringify(s, null, 2));
|
|
82
82
|
}
|
|
83
|
-
} catch { /*
|
|
83
|
+
} catch { /* ignore */ }
|
|
84
84
|
}
|
|
85
|
-
try { rmSync(oldDir, { recursive: true, force: true }); io.log(t("ide.pi.legacyClone")); } catch { /*
|
|
85
|
+
try { rmSync(oldDir, { recursive: true, force: true }); io.log(t("ide.pi.legacyClone")); } catch { /* ignore */ }
|
|
86
86
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
// PI Persona Harness
|
|
2
|
-
// PI skill
|
|
1
|
+
// PI Persona Harness adapter (enable, disable, status).
|
|
2
|
+
// Independent of the PI skill — leaves the skill alone and only toggles the harness registration (settings.json extensions).
|
|
3
3
|
import { existsSync } from "node:fs";
|
|
4
4
|
import { harnessEnabled, harnessAdd, harnessRemove, harnessLoaderPath, piSettingsPath } from "./pi-common.js";
|
|
5
5
|
import { t } from "../../../i18n/index.js";
|
|
6
6
|
|
|
7
|
-
//
|
|
7
|
+
// For this adapter, "installable" depends on pi existing + the loader file existing.
|
|
8
8
|
function available(io) { return !!io.which("pi") && existsSync(harnessLoaderPath(io)); }
|
|
9
9
|
|
|
10
10
|
function detect(io) {
|
|
@@ -13,7 +13,7 @@ function detect(io) {
|
|
|
13
13
|
return { installed: harnessEnabled(io), version: null, cliMissing: false, note: t(harnessEnabled(io) ? "ide.harness.enabled" : "ide.harness.disabled") };
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
// apply = harness
|
|
16
|
+
// apply = enable the harness (skill untouched).
|
|
17
17
|
function apply(io) {
|
|
18
18
|
if (!available(io)) { io.log(t("ide.harness.needPi")); return false; }
|
|
19
19
|
if (harnessEnabled(io)) { io.log(t("ide.harness.already")); return true; }
|
|
@@ -24,7 +24,7 @@ function apply(io) {
|
|
|
24
24
|
return false;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
-
// remove = harness
|
|
27
|
+
// remove = disable only the harness (PI skill kept).
|
|
28
28
|
function remove(io) {
|
|
29
29
|
if (!harnessEnabled(io)) { io.log(t("ide.harness.removeNone")); return true; }
|
|
30
30
|
io.log(t("ide.harness.keepSkill"));
|
|
@@ -35,11 +35,11 @@ function remove(io) {
|
|
|
35
35
|
|
|
36
36
|
function manualHint() { return t("ide.harness.manual"); }
|
|
37
37
|
|
|
38
|
-
//
|
|
38
|
+
// Harness description (reused in prompts).
|
|
39
39
|
export const harnessDesc = () => t("ide.harness.desc");
|
|
40
40
|
|
|
41
41
|
export const piHarnessAdapter = {
|
|
42
42
|
id: "pi-harness", label: "PI Persona Harness", order: 60,
|
|
43
|
-
optional: true, //
|
|
43
|
+
optional: true, // Shown in the menu only when detected (consulted when iterating the registry)
|
|
44
44
|
detect, apply, remove, manualHint,
|
|
45
45
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
// PI
|
|
2
|
-
// pi install/update/remove.
|
|
1
|
+
// PI package adapter (install/remove).
|
|
2
|
+
// pi install/update/remove. Skills are not copied; pi scans them at every startup → install check is 'pi list'.
|
|
3
3
|
import { PI_PACKAGE_URL, piInstalled, harnessEnabled, harnessRemove, migratePiLegacy } from "./pi-common.js";
|
|
4
4
|
import { migrateConfigRoot } from "../legacy.js";
|
|
5
5
|
import { t } from "../../../i18n/index.js";
|
|
@@ -36,7 +36,7 @@ function remove(io) {
|
|
|
36
36
|
io.run("pi", ["remove", PI_PACKAGE_URL]);
|
|
37
37
|
if (piInstalled(io)) io.log(t("ide.pi.stillThere"));
|
|
38
38
|
else io.log(t("ide.pi.removed"));
|
|
39
|
-
// package
|
|
39
|
+
// If the package clone disappears, the harness loader path points at nothing → disable it too
|
|
40
40
|
if (harnessEnabled(io)) { io.log(t("ide.pi.harnessAlso")); harnessRemove(io); }
|
|
41
41
|
return true;
|
|
42
42
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
//
|
|
2
|
-
//
|
|
1
|
+
// Shared install/remove flow for home-copy IDEs (Cursor, Copilot): find source > copy > entry points > log
|
|
2
|
+
// Messages use per-adapter key sets (<messagePrefix>.copying, etc.).
|
|
3
3
|
import { existsSync } from "node:fs";
|
|
4
4
|
import { join } from "node:path";
|
|
5
5
|
import { t } from "../../i18n/index.js";
|
|
@@ -7,7 +7,7 @@ import { resolveSkillsSrc, resolveScriptsSrc, installHomeSkills, removeOwnedEntr
|
|
|
7
7
|
import { refreshStableEntrypoints, projectopsHomeOf } from "./stable-entry.js";
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
|
-
*
|
|
10
|
+
* Install/update: check skill source > copy skills and shared Python > stable entry points > result log
|
|
11
11
|
* options: { skillsDest, metaFileName, messagePrefix }
|
|
12
12
|
*/
|
|
13
13
|
export function applyHomeSkills(io, ctx, { skillsDest, metaFileName, messagePrefix }) {
|
|
@@ -20,7 +20,7 @@ export function applyHomeSkills(io, ctx, { skillsDest, metaFileName, messagePref
|
|
|
20
20
|
skillsSrc, scriptsSrc, skillsDest, metaFileName, templateVersion: ctx.templateVersion,
|
|
21
21
|
});
|
|
22
22
|
for (const name of obsoleteNames) io.log(t("ide.skillsCopy.obsolete", { name }));
|
|
23
|
-
//
|
|
23
|
+
// Without the shared Python, skill CLIs fail on import → notify only (doc-only skills still work)
|
|
24
24
|
if (!hasSharedScripts) io.log(t("ide.skillsCopy.noScripts"));
|
|
25
25
|
io.log(t(`${messagePrefix}.installed`, { dest: skillsDest, version: ctx.templateVersion || "unknown" }));
|
|
26
26
|
} catch (e) {
|
|
@@ -32,7 +32,7 @@ export function applyHomeSkills(io, ctx, { skillsDest, metaFileName, messagePref
|
|
|
32
32
|
return true;
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
//
|
|
35
|
+
// An entry point failure is not an install failure (Python reinstalls it on the first CLI run)
|
|
36
36
|
function installStableEntrypoints(io, skillsSrc, scriptsSrc) {
|
|
37
37
|
try {
|
|
38
38
|
const projectopsHome = projectopsHomeOf(io);
|
|
@@ -42,7 +42,7 @@ function installStableEntrypoints(io, skillsSrc, scriptsSrc) {
|
|
|
42
42
|
} catch { io.log(t("ide.skillsCopy.entrypointFailed")); }
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
//
|
|
45
|
+
// Remove: skip if no meta > delete only our entries and the shared Python (keep the folder if others' skills remain)
|
|
46
46
|
export function removeHomeSkills(io, ctx, { skillsDest, metaFileName, messagePrefix }) {
|
|
47
47
|
if (!existsSync(join(skillsDest, metaFileName))) { io.log(t(`${messagePrefix}.removeNone`)); return true; }
|
|
48
48
|
try {
|
package/src/core/ide/legacy.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
//
|
|
2
|
-
//
|
|
1
|
+
// Shared legacy utilities for IDE adapters — version check + config root migration.
|
|
2
|
+
// Shared when moving pre-rebrand (#459) installs (cassiiopeia/SUH-DEVOPS-TEMPLATE) to the new one (projectops).
|
|
3
3
|
import { join } from "node:path";
|
|
4
4
|
import { existsSync, readFileSync } from "node:fs";
|
|
5
5
|
import { copyFileSync } from "../fsutil.js";
|
|
6
6
|
import { compareCacheName } from "./util.js";
|
|
7
7
|
import { t } from "../../i18n/index.js";
|
|
8
8
|
|
|
9
|
-
// version <= maxLegacy
|
|
9
|
+
// Legacy if version <= maxLegacy. null/empty string cannot be judged → false (safe).
|
|
10
10
|
export function isLegacyVersion(version, maxLegacy) {
|
|
11
11
|
if (!version || !maxLegacy) return false;
|
|
12
12
|
return compareCacheName(String(version), String(maxLegacy)) <= 0;
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
//
|
|
15
|
+
// true if the file exists, parses as JSON and has at least 1 key.
|
|
16
16
|
export function hasNonEmptyJson(path) {
|
|
17
17
|
if (!path || !existsSync(path)) return false;
|
|
18
18
|
try {
|
|
@@ -21,14 +21,14 @@ export function hasNonEmptyJson(path) {
|
|
|
21
21
|
} catch { return false; }
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
//
|
|
25
|
-
//
|
|
24
|
+
// Config root migration: copy from the old path only when the target (~/.projectops/config/config.json) is empty.
|
|
25
|
+
// The old file is not deleted (keeps sensitive values). Idempotent.
|
|
26
26
|
export function migrateConfigRoot(io) {
|
|
27
27
|
const target = join(io.home(), ".projectops", "config", "config.json");
|
|
28
28
|
if (hasNonEmptyJson(target)) return { migrated: false, reason: "target-exists" };
|
|
29
29
|
const sources = [
|
|
30
|
-
join(io.home(), ".suh-template", "config", "config.json"), //
|
|
31
|
-
join(io.home(), ".cassiiopeia", "config.json"), //
|
|
30
|
+
join(io.home(), ".suh-template", "config", "config.json"), // 2nd generation first
|
|
31
|
+
join(io.home(), ".cassiiopeia", "config.json"), // 1st generation fallback
|
|
32
32
|
];
|
|
33
33
|
const src = sources.find(hasNonEmptyJson);
|
|
34
34
|
if (!src) return { migrated: false, reason: "no-source" };
|
package/src/core/ide/registry.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
// IDE
|
|
1
|
+
// IDE adapter registry — the only extension point.
|
|
2
2
|
//
|
|
3
|
-
//
|
|
4
|
-
// 1) src/core/ide/adapters/<name>.js
|
|
5
|
-
// 2)
|
|
6
|
-
//
|
|
3
|
+
// To support a new IDE:
|
|
4
|
+
// 1) write an adapter object (adapter.js contract) in src/core/ide/adapters/<name>.js
|
|
5
|
+
// 2) add the import below and put it in the ADAPTERS array
|
|
6
|
+
// The orchestrator, prompts and index routing only iterate this array, so no other file needs changes.
|
|
7
7
|
import { assertAdapter } from "./adapter.js";
|
|
8
8
|
import { claudeAdapter } from "./adapters/claude.js";
|
|
9
9
|
import { cursorAdapter } from "./adapters/cursor.js";
|
|
@@ -13,7 +13,7 @@ import { copilotAdapter } from "./adapters/copilot.js";
|
|
|
13
13
|
import { piAdapter } from "./adapters/pi.js";
|
|
14
14
|
import { piHarnessAdapter } from "./adapters/pi-harness.js";
|
|
15
15
|
|
|
16
|
-
// order
|
|
16
|
+
// Sort by order ascending + check the contract.
|
|
17
17
|
export const ADAPTERS = [
|
|
18
18
|
claudeAdapter,
|
|
19
19
|
cursorAdapter,
|
package/src/core/ide/runner.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
//
|
|
2
|
-
//
|
|
1
|
+
// Wrapper for running and detecting external CLIs.
|
|
2
|
+
// Everything is injectable — tests pass stub runner/which/home to verify without real CLIs.
|
|
3
3
|
import { spawnSync } from "node:child_process";
|
|
4
4
|
import { delimiter, join } from "node:path";
|
|
5
5
|
import { existsSync } from "node:fs";
|
|
6
6
|
import { homedir } from "node:os";
|
|
7
7
|
|
|
8
|
-
// which(cmd) →
|
|
9
|
-
// Windows
|
|
8
|
+
// which(cmd) → absolute path of the executable or null. Scans PATH directly (built-ins only, no execa).
|
|
9
|
+
// On Windows, also tries PATHEXT extensions (.cmd/.exe/.bat, etc.).
|
|
10
10
|
export function which(cmd) {
|
|
11
11
|
const paths = (process.env.PATH || "").split(delimiter).filter(Boolean);
|
|
12
12
|
const exts = process.platform === "win32"
|
|
@@ -21,13 +21,13 @@ export function which(cmd) {
|
|
|
21
21
|
return null;
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
// run(cmd, args, opts) → {code, stdout, stderr}.
|
|
25
|
-
// opts.cwd
|
|
24
|
+
// run(cmd, args, opts) → {code, stdout, stderr}. Synchronous.
|
|
25
|
+
// Supports opts.cwd and opts.env. If the launch itself fails (no file, etc.), code=127.
|
|
26
26
|
//
|
|
27
|
-
// Windows: claude/gemini/codex/pi
|
|
28
|
-
// shell:true + args
|
|
29
|
-
//
|
|
30
|
-
//
|
|
27
|
+
// Windows: claude/gemini/codex/pi are .cmd/.ps1 shell launchers that spawnSync cannot start directly.
|
|
28
|
+
// shell:true + an args array triggers the DEP0190 (unescaped args) warning → pass cmd.exe a single safely quoted
|
|
29
|
+
// command string. args are only our hardcoded values + URL/scope, so they are trusted,
|
|
30
|
+
// but they are still wrapped in double quotes to guard against spaces and special characters.
|
|
31
31
|
export function run(cmd, args = [], opts = {}) {
|
|
32
32
|
const common = { cwd: opts.cwd, env: opts.env || process.env, encoding: "utf8", windowsHide: true };
|
|
33
33
|
let r;
|
|
@@ -35,27 +35,27 @@ export function run(cmd, args = [], opts = {}) {
|
|
|
35
35
|
const line = [cmd, ...args].map(winQuote).join(" ");
|
|
36
36
|
r = spawnSync(line, { ...common, shell: true });
|
|
37
37
|
} else {
|
|
38
|
-
r = spawnSync(cmd, args, common); // POSIX
|
|
38
|
+
r = spawnSync(cmd, args, common); // POSIX needs no shell (safe)
|
|
39
39
|
}
|
|
40
40
|
if (r.error) return { code: 127, stdout: "", stderr: String(r.error.message || r.error) };
|
|
41
41
|
return { code: r.status ?? 0, stdout: r.stdout || "", stderr: r.stderr || "" };
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
// cmd.exe
|
|
44
|
+
// Quoting for cmd.exe: tokens already safe (alphanumerics, path and URL characters) as is, else wrap in "..." and escape inner ".
|
|
45
45
|
function winQuote(s) {
|
|
46
46
|
if (/^[A-Za-z0-9_./:@=-]+$/.test(s)) return s;
|
|
47
47
|
return '"' + String(s).replace(/"/g, '\\"') + '"';
|
|
48
48
|
}
|
|
49
49
|
|
|
50
|
-
// IDE
|
|
50
|
+
// Default IDE run context. Tests replace this shape with a stub.
|
|
51
51
|
// which(cmd)→path|null, run(cmd,args)→{code,stdout,stderr}, home()→string, log(msg)
|
|
52
52
|
export function defaultIo() {
|
|
53
53
|
return {
|
|
54
54
|
which,
|
|
55
55
|
run,
|
|
56
56
|
home: () => homedir(),
|
|
57
|
-
//
|
|
57
|
+
// Same rule as Python stable_entry: PROJECTOPS_HOME > ~/.projectops
|
|
58
58
|
projectopsHome: () => process.env.PROJECTOPS_HOME || join(homedir(), ".projectops"),
|
|
59
|
-
log: (msg) => console.error(msg), //
|
|
59
|
+
log: (msg) => console.error(msg), // Notices go to stderr (keeps the stdout pipe clean)
|
|
60
60
|
};
|
|
61
61
|
}
|
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
//
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
// (
|
|
1
|
+
// Shared skill folder copy (Cursor, Copilot): skills/ + shared Python scripts/ > home install root, tests excluded, obsolete cleanup, meta record
|
|
2
|
+
// Kept in one place so IDEs that read SKILL.md folders directly without a marketplace use the same rules.
|
|
3
|
+
// Install layout matches the plugin cache: <install root>/skills/pro-*/scripts/x_cli.py + <install root>/scripts/common
|
|
4
|
+
// (the skill CLI bootstrap uses scripts/ three levels above x_cli.py as an import path)
|
|
5
5
|
import { dirname, join, relative } from "node:path";
|
|
6
6
|
import { existsSync, readFileSync, mkdirSync, rmSync, writeFileSync, readdirSync } from "node:fs";
|
|
7
7
|
import { copyPathSync } from "../fsutil.js";
|
|
8
8
|
import { TEMPLATE_REPO_WEB_URL } from "../paths.js";
|
|
9
9
|
|
|
10
|
-
//
|
|
11
|
-
// skills/
|
|
10
|
+
// Not needed by skill users. These are tests that check projectops itself.
|
|
11
|
+
// skills/ is copied whole, so without filtering here they pile up in the user's home.
|
|
12
12
|
export const SKIP_IN_COPY = new Set(["conftest.py", "pytest.ini"]);
|
|
13
13
|
export const TEST_PATH = /(^|[\\/])(tests?|__pycache__)([\\/]|$)/;
|
|
14
|
-
//
|
|
14
|
+
// Our skill prefixes: pro- current, suh- old name
|
|
15
15
|
const OWNED_SKILL_NAME = /^(pro|suh)-/;
|
|
16
|
-
//
|
|
16
|
+
// Shared Python package marker: scripts/common/__init__.py
|
|
17
17
|
const SHARED_SCRIPTS_MARKER = join("common", "__init__.py");
|
|
18
18
|
export const SHARED_SCRIPTS_DIR_NAME = "scripts";
|
|
19
19
|
const PYTHON_CACHE_DIR_NAME = "__pycache__";
|
|
20
|
-
//
|
|
21
|
-
//
|
|
22
|
-
//
|
|
20
|
+
// 3 top-level shared Python entries used only by repo maintainers: guide doc, troubleshooting index generator, extras copy sync (#988)
|
|
21
|
+
// Why an exclude list, not an allow list: missing a new runtime module kills skills on import,
|
|
22
|
+
// while missing a new dev file only ships one extra file. test/ide-home-install-e2e.test.js catches runtime entries landing here
|
|
23
23
|
export const SHARED_SCRIPTS_DEV_ONLY = new Set(["README.md", "build_troubleshooting.py", "sync_extras.py"]);
|
|
24
24
|
|
|
25
|
-
//
|
|
25
|
+
// Skill source: downloaded template (TEMP)/skills first, else local skills/
|
|
26
26
|
export function resolveSkillsSrc(ctx = {}) {
|
|
27
27
|
const cands = [ctx.sourceSkillsDir, ctx.tempDir && join(ctx.tempDir, "skills"), "skills"].filter(Boolean);
|
|
28
28
|
for (const c of cands) if (existsSync(c)) return c;
|
|
29
29
|
return "";
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
//
|
|
32
|
+
// Shared Python source: explicit > template (TEMP)/scripts > scripts/ next to the skill source (same repo)
|
|
33
33
|
export function resolveScriptsSrc(ctx = {}, skillsSrc = "") {
|
|
34
34
|
const cands = [ctx.sourceScriptsDir, ctx.tempDir && join(ctx.tempDir, SHARED_SCRIPTS_DIR_NAME),
|
|
35
35
|
skillsSrc && join(dirname(skillsSrc), SHARED_SCRIPTS_DIR_NAME)].filter(Boolean);
|
|
@@ -37,7 +37,7 @@ export function resolveScriptsSrc(ctx = {}, skillsSrc = "") {
|
|
|
37
37
|
return "";
|
|
38
38
|
}
|
|
39
39
|
|
|
40
|
-
//
|
|
40
|
+
// Meta file > {installed, version, sharedScripts} (corrupt meta counts as installed)
|
|
41
41
|
export function readSkillsMeta(metaFile) {
|
|
42
42
|
if (!existsSync(metaFile)) return { installed: false, version: null, sharedScripts: [] };
|
|
43
43
|
try {
|
|
@@ -46,15 +46,15 @@ export function readSkillsMeta(metaFile) {
|
|
|
46
46
|
} catch { return { installed: true, version: null, sharedScripts: [] }; }
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
//
|
|
50
|
-
//
|
|
51
|
-
// skipNames:
|
|
49
|
+
// Copy top-level source entries (tests and conftest excluded). The filter uses paths relative to the source —
|
|
50
|
+
// with absolute paths, everything would be filtered when the source sits under ~/test/....
|
|
51
|
+
// skipNames: extra top-level names to leave out (dev-only shared Python entries)
|
|
52
52
|
function copyEntriesWithoutTests(src, dest, skipNames = new Set()) {
|
|
53
53
|
mkdirSync(dest, { recursive: true });
|
|
54
54
|
const copiedNames = [];
|
|
55
55
|
for (const e of readdirSync(src, { withFileTypes: true })) {
|
|
56
56
|
if (SKIP_IN_COPY.has(e.name) || TEST_PATH.test(e.name) || skipNames.has(e.name)) continue;
|
|
57
|
-
//
|
|
57
|
+
// Tests that check this repo's own code have no reason to go to someone else's computer (#591).
|
|
58
58
|
copyPathSync(join(src, e.name), join(dest, e.name), (p) => !TEST_PATH.test(relative(src, p)));
|
|
59
59
|
copiedNames.push(e.name);
|
|
60
60
|
}
|
|
@@ -62,13 +62,13 @@ function copyEntriesWithoutTests(src, dest, skipNames = new Set()) {
|
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
/**
|
|
65
|
-
*
|
|
66
|
-
*
|
|
65
|
+
* Copy skills: source > dest (tests excluded) > remove our skills that vanished from the source
|
|
66
|
+
* Returns the list of obsolete skill names. Copy failures are thrown (the caller logs and returns false).
|
|
67
67
|
*/
|
|
68
68
|
export function copySkillsTree(src, dest, metaFileName) {
|
|
69
69
|
copyEntriesWithoutTests(src, dest);
|
|
70
|
-
//
|
|
71
|
-
//
|
|
70
|
+
// The copy is an overlay, so overwriting alone leaves **obsolete skills on users' computers forever**, still picked up (#500).
|
|
71
|
+
// Others' skills are filtered out by prefix and left untouched.
|
|
72
72
|
const srcNames = new Set(readdirSync(src));
|
|
73
73
|
const obsoleteNames = [];
|
|
74
74
|
for (const name of readdirSync(dest)) {
|
|
@@ -77,21 +77,21 @@ export function copySkillsTree(src, dest, metaFileName) {
|
|
|
77
77
|
try {
|
|
78
78
|
rmSync(join(dest, name), { recursive: true, force: true });
|
|
79
79
|
obsoleteNames.push(name);
|
|
80
|
-
} catch { /*
|
|
80
|
+
} catch { /* ignore — keep installing even if it cannot be deleted */ }
|
|
81
81
|
}
|
|
82
82
|
return obsoleteNames;
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
-
//
|
|
85
|
+
// Replace-copy the shared Python: remove last install's entries > copy runtime entries only (so obsolete modules and old dev files do not linger). Returns copied entry names
|
|
86
86
|
function replaceSharedScripts(scriptsSrc, scriptsDest, previousNames) {
|
|
87
87
|
removeNamedEntries(scriptsDest, previousNames);
|
|
88
88
|
return copyEntriesWithoutTests(scriptsSrc, scriptsDest, SHARED_SCRIPTS_DEV_ONLY);
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
-
//
|
|
91
|
+
// Delete the name list + __pycache__ made by Python runs > delete the folder too if empty
|
|
92
92
|
function removeNamedEntries(dir, names) {
|
|
93
93
|
for (const name of [...names, PYTHON_CACHE_DIR_NAME]) {
|
|
94
|
-
//
|
|
94
|
+
// Names come from meta, so block path traversal (../)
|
|
95
95
|
if (!name || name.includes("/") || name.includes("\\") || name === "..") continue;
|
|
96
96
|
rmSync(join(dir, name), { recursive: true, force: true });
|
|
97
97
|
}
|
|
@@ -99,8 +99,8 @@ function removeNamedEntries(dir, names) {
|
|
|
99
99
|
}
|
|
100
100
|
|
|
101
101
|
/**
|
|
102
|
-
*
|
|
103
|
-
* {obsoleteNames, hasSharedScripts}
|
|
102
|
+
* One home install: copy skills > replace-copy shared Python > record meta
|
|
103
|
+
* Returns {obsoleteNames, hasSharedScripts}. Failures are thrown.
|
|
104
104
|
*/
|
|
105
105
|
export function installHomeSkills({ skillsSrc, scriptsSrc, skillsDest, metaFileName, templateVersion }) {
|
|
106
106
|
const metaFile = join(skillsDest, metaFileName);
|
|
@@ -112,18 +112,18 @@ export function installHomeSkills({ skillsSrc, scriptsSrc, skillsDest, metaFileN
|
|
|
112
112
|
return { obsoleteNames, hasSharedScripts: !!scriptsSrc };
|
|
113
113
|
}
|
|
114
114
|
|
|
115
|
-
//
|
|
116
|
-
//
|
|
115
|
+
// Entries considered installed here by projectops: source folder names ∪ pro-/suh- prefixes ∪ meta file
|
|
116
|
+
// Folders without the prefix (others' skills like somansa-tools) are excluded → kept
|
|
117
117
|
export function ownedEntries(dir, ctx, metaFileName) {
|
|
118
118
|
if (!existsSync(dir)) return [];
|
|
119
119
|
let srcNames = new Set();
|
|
120
120
|
const src = resolveSkillsSrc(ctx);
|
|
121
121
|
if (src && existsSync(src)) srcNames = new Set(readdirSync(src));
|
|
122
|
-
//
|
|
122
|
+
// Obsolete skills are not in the source, so srcNames does not catch them (#619).
|
|
123
123
|
return readdirSync(dir).filter((name) => srcNames.has(name) || OWNED_SKILL_NAME.test(name) || name === metaFileName);
|
|
124
124
|
}
|
|
125
125
|
|
|
126
|
-
//
|
|
126
|
+
// Delete only our entries (including shared Python listed in meta) > delete the folder too if empty. Failures are thrown.
|
|
127
127
|
export function removeOwnedEntries(dir, ctx, metaFileName) {
|
|
128
128
|
const { sharedScripts } = readSkillsMeta(join(dir, metaFileName));
|
|
129
129
|
for (const name of ownedEntries(dir, ctx, metaFileName)) rmSync(join(dir, name), { recursive: true, force: true });
|
|
@@ -132,13 +132,13 @@ export function removeOwnedEntries(dir, ctx, metaFileName) {
|
|
|
132
132
|
if (sharedScripts.length && existsSync(scriptsDest)) removeNamedEntries(scriptsDest, sharedScripts);
|
|
133
133
|
}
|
|
134
134
|
|
|
135
|
-
//
|
|
135
|
+
// Record meta: for version tracking (installedAt keeps the first install time). extraFields: sharedScripts, etc.
|
|
136
136
|
export function writeSkillsMeta(destDir, metaFileName, templateVersion, extraFields = {}) {
|
|
137
137
|
const version = templateVersion || "unknown";
|
|
138
138
|
const now = new Date().toISOString().replace(/\.\d+Z$/, "Z");
|
|
139
139
|
const file = join(destDir, metaFileName);
|
|
140
140
|
let installedAt = now;
|
|
141
|
-
if (existsSync(file)) { try { installedAt = JSON.parse(readFileSync(file, "utf8")).installedAt || now; } catch { /*
|
|
141
|
+
if (existsSync(file)) { try { installedAt = JSON.parse(readFileSync(file, "utf8")).installedAt || now; } catch { /* harmless */ } }
|
|
142
142
|
const meta = {
|
|
143
143
|
name: "projectops", version, scope: "user",
|
|
144
144
|
source: TEMPLATE_REPO_WEB_URL,
|
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
//
|
|
2
|
-
// SKILL.md
|
|
3
|
-
//
|
|
4
|
-
//
|
|
1
|
+
// Install stable entry points: ~/.projectops/bin/{projectops_cli.py, launch_cli.py} (#942·#897)
|
|
2
|
+
// SKILL.md calls these entry points first. The Python side installs them only after a CLI runs once, so
|
|
3
|
+
// home-copy installs (Cursor, Copilot) lay them down at install time so the first call finds its way (#200).
|
|
4
|
+
// Same rule as Python refresh_stable_entrypoint: overwrite only when the source RESOLVER_REVISION is higher than the installed one.
|
|
5
5
|
import { join } from "node:path";
|
|
6
6
|
import { existsSync, readFileSync, mkdirSync, writeFileSync, chmodSync, renameSync } from "node:fs";
|
|
7
7
|
|
|
8
8
|
const REVISION_PATTERN = /^RESOLVER_REVISION = (\d+)/m;
|
|
9
|
-
//
|
|
9
|
+
// Entry point permissions: directly executable (rwxr-xr-x)
|
|
10
10
|
const STABLE_ENTRYPOINT_MODE = 0o755;
|
|
11
|
-
//
|
|
11
|
+
// 2 entry points: (install name, source path computation)
|
|
12
12
|
const STABLE_ENTRYPOINTS = [
|
|
13
13
|
{ name: "projectops_cli.py", source: ({ scriptsSrc }) => scriptsSrc && join(scriptsSrc, "projectops_cli.py") },
|
|
14
14
|
{ name: "launch_cli.py", source: ({ skillsSrc }) => skillsSrc && join(skillsSrc, "pro-launch", "scripts", "launch_resolver.py") },
|
|
15
15
|
];
|
|
16
16
|
|
|
17
|
-
//
|
|
17
|
+
// File > content revision (-1 if missing or unreadable)
|
|
18
18
|
function readRevision(file) {
|
|
19
19
|
try {
|
|
20
20
|
const match = REVISION_PATTERN.exec(readFileSync(file, "utf8"));
|
|
@@ -23,8 +23,8 @@ function readRevision(file) {
|
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
/**
|
|
26
|
-
*
|
|
27
|
-
*
|
|
26
|
+
* Refresh entry points: only when source revision > installed revision: temp file > permissions > replace
|
|
27
|
+
* Returns the names of replaced entry points. Failures are thrown.
|
|
28
28
|
*/
|
|
29
29
|
export function refreshStableEntrypoints(projectopsHome, sources) {
|
|
30
30
|
const binDir = join(projectopsHome, "bin");
|
|
@@ -35,7 +35,7 @@ export function refreshStableEntrypoints(projectopsHome, sources) {
|
|
|
35
35
|
const target = join(binDir, entry.name);
|
|
36
36
|
if (readRevision(sourceFile) <= readRevision(target)) continue;
|
|
37
37
|
mkdirSync(binDir, { recursive: true });
|
|
38
|
-
//
|
|
38
|
+
// So another session reading at the same time never sees a half-written file
|
|
39
39
|
const temporary = `${target}.${process.pid}.tmp`;
|
|
40
40
|
writeFileSync(temporary, readFileSync(sourceFile, "utf8"));
|
|
41
41
|
chmodSync(temporary, STABLE_ENTRYPOINT_MODE);
|
|
@@ -45,7 +45,7 @@ export function refreshStableEntrypoints(projectopsHome, sources) {
|
|
|
45
45
|
return updatedNames;
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
// projectops
|
|
48
|
+
// projectops home: the io value if given (test isolation), else ~/.projectops
|
|
49
49
|
export function projectopsHomeOf(io) {
|
|
50
50
|
return typeof io.projectopsHome === "function" ? io.projectopsHome() : join(io.home(), ".projectops");
|
|
51
51
|
}
|
package/src/core/ide/util.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
//
|
|
1
|
+
// Shared utilities for IDE adapters.
|
|
2
2
|
|
|
3
|
-
// sort -V
|
|
3
|
+
// Approximation of sort -V: comparator for version-like directories/strings. Sorts "3.0.9" < "3.0.10" correctly.
|
|
4
4
|
export function compareCacheName(a, b) {
|
|
5
5
|
const pa = a.split(".").map((n) => parseInt(n, 10) || 0);
|
|
6
6
|
const pb = b.split(".").map((n) => parseInt(n, 10) || 0);
|
|
@@ -11,8 +11,8 @@ export function compareCacheName(a, b) {
|
|
|
11
11
|
return a.localeCompare(b);
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
//
|
|
14
|
+
// Status → display tag (" ✓ latest" / " → update available: vX"). Empty string without templateVersion.
|
|
15
15
|
export function versionTag(installedVersion, templateVersion) {
|
|
16
16
|
if (!templateVersion || !installedVersion) return "";
|
|
17
|
-
return installedVersion === templateVersion ? " ✓
|
|
17
|
+
return installedVersion === templateVersion ? " ✓ latest" : ` → update available: v${templateVersion}`;
|
|
18
18
|
}
|