pan-stack-cli 0.2.1 → 0.2.2

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 (59) hide show
  1. package/README.md +37 -731
  2. package/bin/pan.js +4955 -269
  3. package/package.json +17 -5
  4. package/lib/ai-skills.js +0 -829
  5. package/lib/create.js +0 -105
  6. package/lib/discover.js +0 -294
  7. package/lib/git/git-checkout.js +0 -395
  8. package/lib/git/git-clone.js +0 -206
  9. package/lib/git/git-fetch-all.js +0 -129
  10. package/lib/git/git-grv.js +0 -125
  11. package/lib/git/git-gst.js +0 -165
  12. package/lib/git/git-mr.js +0 -546
  13. package/lib/git/git-pull.js +0 -137
  14. package/lib/git/git-push.js +0 -185
  15. package/lib/git/git-sync-main.js +0 -334
  16. package/lib/git/helpers/bulk-report.js +0 -202
  17. package/lib/git/helpers/cli.js +0 -188
  18. package/lib/git/helpers/colors.js +0 -19
  19. package/lib/git/helpers/git.js +0 -136
  20. package/lib/git/helpers/manifest.js +0 -223
  21. package/lib/git/helpers/repo-select.js +0 -416
  22. package/lib/git/helpers/repo-summary.js +0 -161
  23. package/lib/i18n.js +0 -61
  24. package/lib/inquirer-theme.js +0 -20
  25. package/lib/language.js +0 -121
  26. package/lib/languages.js +0 -14
  27. package/lib/manifest.js +0 -467
  28. package/lib/menu-prompt.js +0 -201
  29. package/lib/menu.js +0 -134
  30. package/lib/messages.js +0 -647
  31. package/lib/platform.js +0 -140
  32. package/lib/run-command.js +0 -334
  33. package/lib/select.js +0 -0
  34. package/lib/serve.js +0 -75
  35. package/lib/skill-registry-client.js +0 -173
  36. package/lib/stats/aggregate.js +0 -51
  37. package/lib/stats/identity.js +0 -20
  38. package/lib/stats/index.js +0 -189
  39. package/lib/stats/parse.js +0 -46
  40. package/lib/stats/range.js +0 -38
  41. package/lib/stats/report.js +0 -264
  42. package/lib/stats/review.js +0 -157
  43. package/lib/stats/scan.js +0 -92
  44. package/lib/stats/serve.js +0 -25
  45. package/lib/ui/api.js +0 -202
  46. package/lib/ui/clone.js +0 -115
  47. package/lib/ui/config.js +0 -182
  48. package/lib/ui/diff.js +0 -128
  49. package/lib/ui/export-gate.js +0 -79
  50. package/lib/ui/gen-react-mobile-code.js +0 -6
  51. package/lib/ui/gen-react-web-code.js +0 -75
  52. package/lib/ui/index.js +0 -89
  53. package/lib/ui/init.js +0 -252
  54. package/lib/ui/login.js +0 -128
  55. package/lib/ui/logout.js +0 -22
  56. package/lib/ui/palettes.js +0 -103
  57. package/lib/ui/published-html.js +0 -24
  58. package/lib/ui/sync.js +0 -137
  59. package/lib/ui/workspace.js +0 -213
@@ -1,129 +0,0 @@
1
- #!/usr/bin/env node
2
- /*
3
- * Fetch all remotes for PAN Stack project repositories.
4
- * Compact summary table: repo · branch · fetched · behind/ahead · new refs.
5
- */
6
-
7
- const { parseCommonArgs, loadManifestRepos, printCommonOptions } = require("./helpers/cli");
8
- const { ensureRepoExists } = require("./helpers/git");
9
- const {
10
- runGitSilent, parseFetchOutput, printSummary, statusBadge, bulkColumns,
11
- aheadBehind, getCurrentBranch, ICON,
12
- } = require("./helpers/bulk-report");
13
- const colors = require("./helpers/colors");
14
- const { t } = require("../i18n");
15
-
16
- function fetchRepo({ name, destination, dryRun }) {
17
- if (!ensureRepoExists({ name, destination })) {
18
- return { name, skipped: true };
19
- }
20
- const branch = getCurrentBranch(destination) || t("GST_DETACHED");
21
-
22
- if (dryRun) {
23
- console.log(colors.dim(`[dry-run] (in ${destination}) git fetch --all`));
24
- return { name, branch, dryRun: true };
25
- }
26
-
27
- process.stdout.write(colors.dim(` ⇣ ${name} (${branch}) ... `));
28
- const res = runGitSilent(["fetch", "--all", "--prune"], destination);
29
- const parsed = parseFetchOutput(res.stdout, res.stderr);
30
- const ab = aheadBehind(destination);
31
- const ok = res.status === 0;
32
- const shortMsg = !ok ? t("BULK_STATUS_FAILED")
33
- : (parsed.newBranches || parsed.updatedBranches || parsed.newTags) ? t("BULK_STATUS_UPDATED")
34
- : t("BULK_STATUS_OK");
35
- console.log((ok ? colors.green : colors.red)(shortMsg));
36
-
37
- return {
38
- name, branch,
39
- status: res.status,
40
- ...parsed,
41
- ahead: ab ? ab.ahead : 0,
42
- behind: ab ? ab.behind : 0,
43
- hasUpstream: Boolean(ab),
44
- error: !ok ? (res.stderr.split("\n")[0] || "").slice(0, 80) : "",
45
- };
46
- }
47
-
48
- function row(r) {
49
- if (r.skipped) return { repo: colors.dim(r.name), branch: "", result: colors.dim(t("BULK_STATUS_SKIPPED")), sync: "", refs: "" };
50
- if (r.dryRun) return { repo: r.name, branch: r.branch, result: colors.dim(t("BULK_STATUS_DRY_RUN")), sync: "", refs: "" };
51
- const result = r.error ? statusBadge("fail", t("BULK_STATUS_FAILED")) : statusBadge("ok", t("BULK_STATUS_FETCHED"));
52
- let sync;
53
- if (!r.hasUpstream) sync = colors.dim(t("BULK_STATUS_NO_UPSTREAM"));
54
- else if (r.behind === 0 && r.ahead === 0) sync = colors.green(t("BULK_STATUS_IN_SYNC"));
55
- else {
56
- const parts = [];
57
- if (r.behind) parts.push(colors.yellow(`${ICON.down} ${r.behind}`));
58
- if (r.ahead) parts.push(colors.cyan(`${ICON.up} ${r.ahead}`));
59
- sync = parts.join(" ");
60
- }
61
- const refBits = [];
62
- if (r.newBranches) refBits.push(t("BULK_REFS_NEW__N", { n: r.newBranches }));
63
- if (r.updatedBranches) refBits.push(t("BULK_REFS_UPD__N", { n: r.updatedBranches }));
64
- if (r.newTags) refBits.push(t("BULK_REFS_TAGS__N", { n: r.newTags }));
65
- if (r.prunedRefs) refBits.push(t("BULK_REFS_PRUNED__N", { n: r.prunedRefs }));
66
- const refs = refBits.length ? refBits.join(" · ") : colors.dim("—");
67
- return { repo: r.name, branch: r.branch, result, sync, refs };
68
- }
69
-
70
- function printHelp() {
71
- console.log(`usage: git-fetch-all.js [--base-dir BASE_DIR] [--dry-run] [manifest]
72
-
73
- Fetch all remotes for repositories listed in a PAN Stack clone manifest.
74
- Prints a compact summary table (repo · branch · result · behind/ahead · new refs).
75
-
76
- ${printCommonOptions()}`);
77
- }
78
-
79
- function main() {
80
- const args = parseCommonArgs(process.argv.slice(2));
81
- if (args.help) { printHelp(); return; }
82
-
83
- const { repos } = loadManifestRepos({ manifestPath: args.manifest, baseDir: args.baseDir });
84
- const results = repos.map((r) => fetchRepo({ name: r.name, destination: r.destination, dryRun: args.dryRun }));
85
-
86
- const behind = results.filter((r) => r.behind > 0);
87
- const failed = results.filter((r) => r.error);
88
- const hasNewRefs = (r) => (r.newBranches || r.updatedBranches || r.newTags || r.prunedRefs) > 0;
89
- const changed = results.filter((r) => !r.skipped && (hasNewRefs(r) || r.behind > 0 || r.ahead > 0 || r.error));
90
- const inSyncCount = results.length - changed.length - results.filter((r) => r.skipped).length;
91
- // Chỉ đưa vào bảng: có ref mới / behind-ahead / lỗi / dry-run.
92
- const shown = results.filter((r) => r.dryRun || (!r.skipped && (hasNewRefs(r) || r.behind > 0 || r.ahead > 0 || r.error)));
93
- const rows = shown.map(row);
94
-
95
- const footer = [];
96
- footer.push(colors.dim(t("FETCH_FOOTER_COUNTS__TOTAL_CHANGED_INSYNC_BEHIND_FAILED", {
97
- total: results.length, changed: changed.length, inSync: inSyncCount,
98
- behind: behind.length, failed: failed.length,
99
- })));
100
- if (behind.length) {
101
- footer.push("");
102
- footer.push(colors.yellow(t("FETCH_BEHIND_HEADER")));
103
- for (const r of behind) footer.push(` ${colors.cyan(r.name)} (${r.branch}): ${ICON.down} ${r.behind}`);
104
- }
105
-
106
- if (rows.length === 0) {
107
- console.log("");
108
- console.log(colors.bold(`─── ${t("FETCH_TITLE")} ───`));
109
- console.log(colors.green(t("FETCH_ALL_IN_SYNC__N", { n: results.length })));
110
- for (const line of footer) console.log(line);
111
- } else {
112
- printSummary({
113
- title: t("FETCH_TITLE"),
114
- rows,
115
- columns: bulkColumns([
116
- { key: "repo", labelKey: "BULK_COL_REPO" },
117
- { key: "branch", labelKey: "BULK_COL_BRANCH" },
118
- { key: "result", labelKey: "BULK_COL_RESULT" },
119
- { key: "sync", labelKey: "BULK_COL_SYNC" },
120
- { key: "refs", labelKey: "BULK_COL_NEW_REFS" },
121
- ]),
122
- footerLines: footer,
123
- });
124
- }
125
-
126
- if (failed.length) process.exitCode = 1;
127
- }
128
-
129
- try { main(); } catch (error) { console.error(error.message); process.exit(1); }
@@ -1,125 +0,0 @@
1
- #!/usr/bin/env node
2
- /*
3
- * List git remotes (git remote -v) for PAN Stack project repositories.
4
- * Compact summary table (giống pull/push/fetch): repo · branch · remote · fetch · push.
5
- */
6
-
7
- const { parseCommonArgs, loadManifestRepos, printCommonOptions } = require("./helpers/cli");
8
- const { ensureRepoExists, isGitRepo, listRemotesVerbose, getCurrentBranch } = require("./helpers/git");
9
- const { printSummary, bulkColumns } = require("./helpers/bulk-report");
10
- const colors = require("./helpers/colors");
11
- const { t } = require("../i18n");
12
-
13
- // `git remote -v` in 2 dòng/remote ("origin\tURL (fetch)" / "origin\tURL (push)") — gộp lại
14
- // thành { name: { fetch, push } } theo tên remote.
15
- function parseRemotes(lines) {
16
- const byName = new Map();
17
- for (const line of lines) {
18
- const m = line.match(/^(\S+)\s+(\S+)\s+\((fetch|push)\)$/);
19
- if (!m) continue;
20
- const [, name, url, kind] = m;
21
- if (!byName.has(name)) byName.set(name, { name, fetch: "", push: "" });
22
- byName.get(name)[kind] = url;
23
- }
24
- return [...byName.values()];
25
- }
26
-
27
- function repoRow({ label, destination, dryRun }) {
28
- if (dryRun) {
29
- console.log(colors.dim(`[dry-run] (in ${destination}) git remote -v`));
30
- return null;
31
- }
32
- const branch = getCurrentBranch(destination) || t("GST_DETACHED");
33
- const remotes = parseRemotes(listRemotesVerbose(destination));
34
- return { name: label, branch, remotes };
35
- }
36
-
37
- function row(r) {
38
- if (r.skipped) {
39
- return { repo: colors.dim(r.name), branch: "", remote: colors.dim(t("BULK_STATUS_SKIPPED")), fetch: "", push: "" };
40
- }
41
- if (r.remotes.length === 0) {
42
- return { repo: r.name, branch: r.branch, remote: colors.dim(t("GRV_NO_REMOTES")), fetch: "", push: "" };
43
- }
44
- // Ưu tiên hiện 'origin' trên dòng đầu; nếu có remote khác, gộp tên (vd "origin (+1)").
45
- const primary = r.remotes.find((rm) => rm.name === "origin") || r.remotes[0];
46
- const remoteLabel = r.remotes.length > 1 ? `${primary.name} (+${r.remotes.length - 1})` : primary.name;
47
- const push = primary.push === primary.fetch ? colors.dim(t("GRV_PUSH_SAME_AS_FETCH")) : primary.push;
48
- return { repo: r.name, branch: r.branch, remote: remoteLabel, fetch: primary.fetch, push };
49
- }
50
-
51
- function printHelp() {
52
- console.log(`usage: git-grv.js [--base-dir BASE_DIR] [--dry-run] [--no-workspace] [manifest]
53
-
54
- List git remotes (git remote -v) for each repository — compact summary table
55
- (repo · branch · remote · fetch · push; push = '=' khi giống fetch).
56
-
57
- ${printCommonOptions()}
58
- --no-workspace Skip workspace root (manifest repos only)`);
59
- }
60
-
61
- function main() {
62
- const args = parseCommonArgs(process.argv.slice(2), {
63
- defaults: { noWorkspace: false },
64
- handlers: {
65
- "--no-workspace": (parsed) => {
66
- parsed.noWorkspace = true;
67
- },
68
- },
69
- });
70
- if (args.help) {
71
- printHelp();
72
- return;
73
- }
74
-
75
- const { repos, workspaceRoot } = loadManifestRepos({
76
- manifestPath: args.manifest,
77
- baseDir: args.baseDir,
78
- });
79
-
80
- const results = [];
81
- if (!args.noWorkspace && isGitRepo(workspaceRoot)) {
82
- const r = repoRow({ label: "workspace", destination: workspaceRoot, dryRun: args.dryRun });
83
- if (r) results.push(r);
84
- }
85
-
86
- for (const repo of repos) {
87
- if (!ensureRepoExists({ name: repo.name, destination: repo.destination })) {
88
- results.push({ name: repo.name, skipped: true });
89
- continue;
90
- }
91
- const r = repoRow({ label: repo.name, destination: repo.destination, dryRun: args.dryRun });
92
- if (r) results.push(r);
93
- }
94
-
95
- if (args.dryRun) return;
96
-
97
- const noRemotes = results.filter((r) => !r.skipped && r.remotes.length === 0);
98
- const skipped = results.filter((r) => r.skipped);
99
- const rows = results.map(row);
100
-
101
- const footer = [];
102
- footer.push(colors.dim(
103
- `Total ${results.length} repos · ${results.length - noRemotes.length - skipped.length} with remotes · ${noRemotes.length} no remote · ${skipped.length} skipped`
104
- ));
105
-
106
- printSummary({
107
- title: t("GRV_TITLE"),
108
- rows,
109
- columns: bulkColumns([
110
- { key: "repo", labelKey: "BULK_COL_REPO" },
111
- { key: "branch", labelKey: "BULK_COL_BRANCH" },
112
- { key: "remote", labelKey: "GRV_COL_REMOTE" },
113
- { key: "fetch", labelKey: "GRV_COL_FETCH" },
114
- { key: "push", labelKey: "GRV_COL_PUSH" },
115
- ]),
116
- footerLines: footer,
117
- });
118
- }
119
-
120
- try {
121
- main();
122
- } catch (error) {
123
- console.error(error.message);
124
- process.exit(1);
125
- }
@@ -1,165 +0,0 @@
1
- #!/usr/bin/env node
2
- /*
3
- * Git status for PAN Stack project repositories.
4
- *
5
- * Default: compact summary — only repos with changes and file counts.
6
- * Use --verbose or pass git status args for full git status output.
7
- */
8
-
9
- const { parseCommonArgs, loadManifestRepos, printCommonOptions } = require("./helpers/cli");
10
- const { ensureRepoExists, isGitRepo, runGitStatus } = require("./helpers/git");
11
- const { getRepoStatusSummary, printChangeSummary } = require("./helpers/repo-summary");
12
-
13
- function printRepoStatus({ label, destination, dryRun, gitArgs }) {
14
- const statusArgs = gitArgs.length > 0 ? gitArgs.join(" ") : "";
15
- if (dryRun) {
16
- console.log(`[dry-run] (in ${destination}) git status ${statusArgs}`.trim());
17
- return;
18
- }
19
-
20
- console.log(`== ${label} ==`);
21
- console.log(destination);
22
- runGitStatus(destination, gitArgs);
23
- console.log("");
24
- }
25
-
26
- function collectRepoStatus({ name, destination, dryRun }) {
27
- if (dryRun) {
28
- return {
29
- name,
30
- destination,
31
- branch: "",
32
- total: 0,
33
- staged: 0,
34
- unstaged: 0,
35
- untracked: 0,
36
- dryRun: true,
37
- };
38
- }
39
-
40
- const summary = getRepoStatusSummary(destination);
41
- return {
42
- name,
43
- destination,
44
- ...summary,
45
- };
46
- }
47
-
48
- function printSummaryDryRun({ totalRepos, includeWorkspace, repoCount }) {
49
- console.log("");
50
- console.log("[dry-run] gst summary");
51
- console.log(
52
- `[dry-run] would scan ${totalRepos} repo(s)` +
53
- (includeWorkspace ? " (workspace + manifest)" : " (manifest only)")
54
- );
55
- console.log(`[dry-run] manifest repos: ${repoCount}`);
56
- }
57
-
58
- function printHelp() {
59
- console.log(`usage: git-gst.js [--base-dir BASE_DIR] [--dry-run] [--no-workspace] [--verbose] [manifest] [git status args...]
60
-
61
- Show a compact summary of repos with uncommitted changes (default).
62
- Only dirty repos are listed with file counts; clean repos are hidden.
63
-
64
- ${printCommonOptions()}
65
- --no-workspace Skip workspace root (manifest repos only)
66
- --verbose Full git status for every repo (legacy output)
67
- [git status args] Implies --verbose (e.g. pan gst -sb)`);
68
- }
69
-
70
- function main() {
71
- const args = parseCommonArgs(process.argv.slice(2), {
72
- defaults: { noWorkspace: false, verbose: false, gitArgs: [] },
73
- passthrough: true,
74
- handlers: {
75
- "--no-workspace": (parsed) => {
76
- parsed.noWorkspace = true;
77
- },
78
- "--verbose": (parsed) => {
79
- parsed.verbose = true;
80
- },
81
- },
82
- });
83
- if (args.help) {
84
- printHelp();
85
- return;
86
- }
87
-
88
- const gitArgs = args.gitArgs || [];
89
- const verbose = args.verbose || gitArgs.length > 0;
90
- const { repos, workspaceRoot } = loadManifestRepos({
91
- manifestPath: args.manifest,
92
- baseDir: args.baseDir,
93
- });
94
-
95
- if (verbose) {
96
- if (!args.noWorkspace && isGitRepo(workspaceRoot)) {
97
- printRepoStatus({
98
- label: "workspace",
99
- destination: workspaceRoot,
100
- dryRun: args.dryRun,
101
- gitArgs,
102
- });
103
- }
104
-
105
- for (const repo of repos) {
106
- if (!ensureRepoExists({ name: repo.name, destination: repo.destination })) {
107
- continue;
108
- }
109
- printRepoStatus({
110
- label: repo.name,
111
- destination: repo.destination,
112
- dryRun: args.dryRun,
113
- gitArgs,
114
- });
115
- }
116
- return;
117
- }
118
-
119
- const results = [];
120
-
121
- if (!args.noWorkspace && isGitRepo(workspaceRoot)) {
122
- results.push(
123
- collectRepoStatus({
124
- name: "workspace",
125
- destination: workspaceRoot,
126
- dryRun: args.dryRun,
127
- })
128
- );
129
- }
130
-
131
- for (const repo of repos) {
132
- if (!ensureRepoExists({ name: repo.name, destination: repo.destination })) {
133
- continue;
134
- }
135
- results.push(
136
- collectRepoStatus({
137
- name: repo.name,
138
- destination: repo.destination,
139
- dryRun: args.dryRun,
140
- })
141
- );
142
- }
143
-
144
- if (args.dryRun) {
145
- printSummaryDryRun({
146
- totalRepos: results.length,
147
- includeWorkspace: !args.noWorkspace && isGitRepo(workspaceRoot),
148
- repoCount: repos.length,
149
- });
150
- return;
151
- }
152
-
153
- printChangeSummary({
154
- title: "gst summary",
155
- results,
156
- totalRepos: results.length,
157
- });
158
- }
159
-
160
- try {
161
- main();
162
- } catch (error) {
163
- console.error(error.message);
164
- process.exit(1);
165
- }