please-cli 0.1.1 → 0.1.3

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 (2) hide show
  1. package/dist/cli.js +98 -2
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -23098,7 +23098,7 @@ function escapeRegExp(value) {
23098
23098
  return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
23099
23099
  }
23100
23100
  function getBashWrapper(devMode) {
23101
- const cliCmd = devMode ? `bun run "${process.cwd()}/src/cli.ts"` : "pls";
23101
+ const cliCmd = devMode ? `bun run "${process.cwd()}/src/cli.ts"` : "command pls";
23102
23102
  return `# please-cli wrapper function (${devMode ? "dev mode" : "npm install"})
23103
23103
  pls() {
23104
23104
  export ASK_CLI_WRAPPER=1
@@ -23123,7 +23123,7 @@ pls() {
23123
23123
  function getPowerShellWrapper(devMode) {
23124
23124
  const devPath = process.cwd().replace(/\//g, "\\") + "\\src\\cli.ts";
23125
23125
  const callCmd = devMode ? `$ASK_CLI_PATH = "${devPath}"
23126
- bun run "$ASK_CLI_PATH" @args` : "pls @args";
23126
+ bun run "$ASK_CLI_PATH" @args` : "& (Get-Command pls -CommandType Application) @args";
23127
23127
  return `# please-cli wrapper function (${devMode ? "dev mode" : "npm install"})
23128
23128
  function pls {
23129
23129
  $env:ASK_CLI_WRAPPER = "1"
@@ -23236,6 +23236,94 @@ ${managedBlock}
23236
23236
  return false;
23237
23237
  }
23238
23238
  }
23239
+ function autoUninstallWrapper() {
23240
+ try {
23241
+ const shell = detectShell();
23242
+ let removed = false;
23243
+ if (shell === "bash") {
23244
+ const bashrc = join3(homedir3(), ".bashrc");
23245
+ if (existsSync3(bashrc)) {
23246
+ const content = readFileSync2(bashrc, "utf-8");
23247
+ if (content.includes("pls()")) {
23248
+ const lines = content.split(`
23249
+ `);
23250
+ const newLines = [];
23251
+ let inWrapper = false;
23252
+ for (const line of lines) {
23253
+ if (line.includes("please-cli wrapper function")) {
23254
+ inWrapper = true;
23255
+ continue;
23256
+ }
23257
+ if (inWrapper && line.trim() === "}") {
23258
+ inWrapper = false;
23259
+ continue;
23260
+ }
23261
+ if (!inWrapper) {
23262
+ newLines.push(line);
23263
+ }
23264
+ }
23265
+ writeFileSync3(bashrc, newLines.join(`
23266
+ `), "utf-8");
23267
+ console.log(import_picocolors5.default.green("\u2713 Wrapper removed from ~/.bashrc"));
23268
+ removed = true;
23269
+ }
23270
+ }
23271
+ } else if (shell === "zsh") {
23272
+ const zshrc = join3(homedir3(), ".zshrc");
23273
+ if (existsSync3(zshrc)) {
23274
+ const content = readFileSync2(zshrc, "utf-8");
23275
+ if (content.includes("pls()")) {
23276
+ const lines = content.split(`
23277
+ `);
23278
+ const newLines = [];
23279
+ let inWrapper = false;
23280
+ for (const line of lines) {
23281
+ if (line.includes("please-cli wrapper function")) {
23282
+ inWrapper = true;
23283
+ continue;
23284
+ }
23285
+ if (inWrapper && line.trim() === "}") {
23286
+ inWrapper = false;
23287
+ continue;
23288
+ }
23289
+ if (!inWrapper) {
23290
+ newLines.push(line);
23291
+ }
23292
+ }
23293
+ writeFileSync3(zshrc, newLines.join(`
23294
+ `), "utf-8");
23295
+ console.log(import_picocolors5.default.green("\u2713 Wrapper removed from ~/.zshrc"));
23296
+ removed = true;
23297
+ }
23298
+ }
23299
+ } else if (shell === "powershell") {
23300
+ const userHome = process.env.USERPROFILE || homedir3();
23301
+ const profileCandidates = [
23302
+ join3(userHome, "Documents", "PowerShell", "Microsoft.PowerShell_profile.ps1"),
23303
+ join3(userHome, "Documents", "WindowsPowerShell", "Microsoft.PowerShell_profile.ps1")
23304
+ ];
23305
+ for (const profilePath of profileCandidates) {
23306
+ if (existsSync3(profilePath)) {
23307
+ const content = readFileSync2(profilePath, "utf-8");
23308
+ const blockRegex = new RegExp(`${escapeRegExp(POWERSHELL_WRAPPER_START)}[\\s\\S]*?${escapeRegExp(POWERSHELL_WRAPPER_END)}`, "m");
23309
+ if (blockRegex.test(content)) {
23310
+ const updated = content.replace(blockRegex, "");
23311
+ writeFileSync3(profilePath, updated, "utf-8");
23312
+ console.log(import_picocolors5.default.green(`\u2713 Wrapper removed from ${profilePath}`));
23313
+ removed = true;
23314
+ }
23315
+ }
23316
+ }
23317
+ }
23318
+ if (!removed) {
23319
+ console.log(import_picocolors5.default.yellow("No wrapper found to remove."));
23320
+ }
23321
+ return removed;
23322
+ } catch (error2) {
23323
+ console.error(import_picocolors5.default.red("Failed to remove wrapper:"), error2);
23324
+ return false;
23325
+ }
23326
+ }
23239
23327
  // src/index.ts
23240
23328
  async function main() {
23241
23329
  const args = process.argv.slice(2);
@@ -23243,6 +23331,7 @@ async function main() {
23243
23331
  help: args.includes("--help") || args.includes("-h"),
23244
23332
  setup: args.includes("--setup"),
23245
23333
  install: args.includes("--install"),
23334
+ uninstall: args.includes("--uninstall"),
23246
23335
  dev: args.includes("--dev"),
23247
23336
  changeModel: args.includes("--model")
23248
23337
  };
@@ -23268,6 +23357,7 @@ Flags:
23268
23357
  -h, --help Display this menu and exit
23269
23358
  --setup Run configuration setup
23270
23359
  --install Install shell wrapper
23360
+ --uninstall Remove shell wrapper
23271
23361
  --install --dev Install shell wrapper in dev mode (uses bun + source path)
23272
23362
  --model [name] Change the model (prompts if no name given)
23273
23363
  `);
@@ -23366,6 +23456,12 @@ Flags:
23366
23456
  fe("Done!");
23367
23457
  return;
23368
23458
  }
23459
+ if (flags.uninstall) {
23460
+ we(import_picocolors6.default.cyan("please-cli"));
23461
+ autoUninstallWrapper();
23462
+ fe("Done!");
23463
+ return;
23464
+ }
23369
23465
  we(import_picocolors6.default.cyan("please-cli"));
23370
23466
  let config = loadConfig();
23371
23467
  if (!config) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "please-cli",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "AI-powered shell command assistant",
5
5
  "type": "module",
6
6
  "main": "dist/cli.js",